1 /* 2 * PROJECT: shell32 3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 * PURPOSE: Shell change notification 5 * COPYRIGHT: Copyright 2020 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) 6 */ 7 #pragma once 8 9 #include "CDirectoryList.h" 10 11 // NOTE: Regard to asynchronous procedure call (APC), please see: 12 // https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-sleepex 13 14 class CDirectoryWatcher 15 { 16 public: 17 HANDLE m_hDirectory; 18 WCHAR m_szDirectoryPath[MAX_PATH]; 19 20 static CDirectoryWatcher *Create(LPCWSTR pszDirectoryPath, BOOL fSubTree); 21 static void RequestAllWatchersTermination(); 22 ~CDirectoryWatcher(); 23 24 BOOL IsDead() const; 25 BOOL RestartWatching(); 26 void QuitWatching(); 27 BOOL RequestAddWatcher(); 28 BOOL RequestTermination(); 29 void ReadCompletion(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered); 30 31 protected: 32 BOOL m_fDead; 33 BOOL m_fRecursive; 34 CDirectoryList m_dir_list; 35 OVERLAPPED m_overlapped; 36 37 BOOL CreateAPCThread(); 38 void ProcessNotification(); 39 CDirectoryWatcher(LPCWSTR pszDirectoryPath, BOOL fSubTree); 40 }; 41