0

How does one detect the action of adding/removing a UNC share? I basically just need to know if a share has been added/removed not details about the share itself. A working example would be greatly appreciated.

Thanks SB

SoulBlade
  • 167
  • 1
  • 10

2 Answers2

3

"By monitoring the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares\ I can catch changes to it."

To monitor a registry key... http://delphi.about.com/od/kbwinshell/l/aa052003a.htm

SoulBlade
  • 167
  • 1
  • 10
0

AFAIK there is no callback/event mechanism to be notified of such an event so I think you can only enumerate (poll) and compare to the previous state at intervals.

(or the ugly way: hook WNetAddConnection* and WNetCancelConnection* API's)

Remko
  • 7,214
  • 2
  • 32
  • 52
  • OK, I found another way. By monitoring the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares\ I can catch changes to it. Thanks for the answer. – SoulBlade Jun 17 '10 at 10:37
  • @SoulBlade: You should provide that answer as a "normal" answer and not as a comment. Then people can vote on it (an you can accept it). – gabr Jun 17 '10 at 10:51
  • BTW I thought you wanted to monitor adding/removing a connection to a share (a mapped drive) so my answer doesn't really address your question. – Remko Jun 17 '10 at 11:14
  • :-( Ja, I just wanted to know if someone is sharing (or removing it) a folder. I thought windows might have a message for that. – SoulBlade Jun 17 '10 at 11:49