2

I know how to use FindFirstChangeNotification and related functions in C++ (or FileSystemWatcher in .NET) to obtain directory change notifications in my own program.

What I'm looking for is a way to check whether another process currently has registered a change notification for a certain directory folder.

I.e. I want to have a function that I can ask:

Does process "dropbox.exe" currently monitor "C:\MyFiles"?

I found no way of getting down to the system "repository" where Windows keeps a list of notification handlers for a certain directory.

The closest I came was:

  1. Enumerate all processes with the name "dropbox.exe".
  2. For each process list all file handles it has currently open.

Still, I'm not sure, whether a change notification is actually a file handle at all.

So my question:

How can I see directory change notification handles for a given directory path and a given process ID.

Update 1:

I do hope I'm not asking an XY problem; my primary goal is to see whether Dropbox is actively running and is configured for the currently logged in user.

(I could be completely wrong in my assumption that Dropbox uses Windows directory/file change notifications at all).

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • 1
    I am pretty sure it uses a minifilter driver, that's how it can do downloads on demand. – Alex K. Feb 20 '18 at 12:57
  • 1
    Depending on any program to have called into particular APIs as a way of detecting if that program is doing something is inherently brittle, even if was easy to do cross-process queries of what's opened what (which it definitely is *not*). My version of Dropbox has some useful data in `%localappdata%\dropbox\info.json`, specifically the path to the Dropbox folder. Combined with a simpler check if `dropbox.exe` is running, that may be sufficient. (Of course, the existence of `info.json` is subject to change at any time if the developers so choose.) – Jeroen Mostert Feb 20 '18 at 12:58
  • 1
    I checked out of curiosity, and running `FileSystemWatcher` does create file handle for the related directory. I seriously doubt though that there is no better way to check if dropbox is configured correctly. – Evk Feb 20 '18 at 12:59
  • Thanks! What @JeroenMostert describes is what I'm already doing. Still it could be some old Dropbox installation without any user registration. – Uwe Keim Feb 20 '18 at 13:03
  • 1
    If you have dropbox installed and configured - I'd suggest to download "handle" utility, then run "handle.exe -p dropbox.exe" (or "handle64.exe -p dropbox") and see yourself if target directory is listed. – Evk Feb 20 '18 at 13:05
  • Thanks, @AlexK. Never heard of [File System Minifilter Drivers](https://learn.microsoft.com/en-us/windows-hardware/drivers/ifs/file-system-minifilter-drivers). Sounds interesting. – Uwe Keim Feb 20 '18 at 13:06

0 Answers0