I would avoid binding the API as much as possible. It gets really ugly really fast.
There are two ways to understand that you can approach this. Both methods have several common factors:
ReadDirectoryChangesW API. For a very good implementation of this API, see this article.- You need to minimize your dependencies, so ... Use the Microsoft compiler, a link to the DLL runtime, stick to C as much as possible, etc. This reduces problems. Loading things into shell memory space is already quite problematic.
The first method is to use ReadDirectoryChangesW from the Explorer shell extension, which does nothing. Keep it minimal. I'm sure I saw the do nothing shell extension as an example in some Microsoft docs.
The second method is to pack your code as a DLL and use the system hook to load your DLL only in Explorer. The system hook should only load inside Explorer to prevent false notifications via ReadDirectoryChangesW .
Hope this helps and that you are not using it for something evil.
source share