Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998-1999.
  5. //
  6. // File: DrvNotifArray.cxx
  7. //
  8. // Contents: This file contains the class, CDrvNotifArray.
  9. //
  10. // History: 15-Jul-98 KitmanH Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #pragma once
  14. #include <drvnotif.hxx>
  15. //+---------------------------------------------------------------------------
  16. //
  17. // Class: CDrvNotifArray
  18. //
  19. // Purpose: This class is a wrapper for a global array of
  20. // CDrvNotificationInfo objects
  21. //
  22. // History: 07/15/98 KitmanH created
  23. //
  24. //----------------------------------------------------------------------------
  25. class CDrvNotifArray
  26. {
  27. public:
  28. CDrvNotifArray() : _fAbort( FALSE ) {}
  29. ~CDrvNotifArray()
  30. {
  31. UnregisterDeviceNotifications();
  32. }
  33. void RegisterCatForNotifInRegistry();
  34. void UnregisterDeviceNotifications();
  35. void AddDriveNotification( WCHAR wcDriveLetter, BOOL fNotInRegistry = FALSE );
  36. CDrvNotificationInfo * FindDriveNotificationByHandle( HDEVNOTIFY hNotify );
  37. CDrvNotificationInfo * FindDriveNotification( WCHAR wcDrvLetter );
  38. void RegisterRemovableDrives();
  39. void RegisterDormantEntries()
  40. {
  41. CLock lock( _mutex );
  42. // If the worker thread hasn't been created yet, do so now.
  43. if ( _xWorker.IsNull() )
  44. _xWorker.Set( new CThread( RegisterThread, this ) );
  45. // Tell the worker thread to do work
  46. _evtWorker.Set();
  47. }
  48. void GetAutoMountDrives( BOOL * aDrives )
  49. {
  50. CLock lock( _mutex );
  51. for ( unsigned i = 0; i < _aDriveNotification.Count(); i++ )
  52. {
  53. CDrvNotificationInfo & info = *_aDriveNotification.Get(i);
  54. WCHAR wc = info.GetDrvLetter() - L'A';
  55. Win4Assert( wc < RTL_MAX_DRIVE_LETTERS );
  56. if ( info.IsAutoMount() )
  57. aDrives[ info.GetDrvLetter() - L'A' ] = TRUE;
  58. }
  59. }
  60. private:
  61. static DWORD WINAPI RegisterThread( void * self );
  62. DWORD DoRegisterWork();
  63. CMutexSem _mutex;
  64. BOOL _fAbort;
  65. CDynArrayInPlace<CDrvNotificationInfo *> _aDriveNotification;
  66. CEventSem _evtWorker;
  67. XPtr<CThread> _xWorker;
  68. };