views:

21

answers:

2

Hi

I have several network drives connected to my PC. How can my application (VC++/Win32) on this PC, hook or get event when user disconnect drive? (Right click menu, Disconnect item).

Thank a lot, Dmitry

A: 

Probably you should have a listener that would catch this event. You can use WNetGetConnection and check for the return code. Here's the link where you could find details about this method : http://msdn.microsoft.com/en-us/library/aa385453.aspx

Owen
A: 

Thanks Owen! Okay, if I use WNetGetConnection, I need to call it every time in loop. For example, every 5 seconds. Is it normal? I think, its not better way. May be SHChangeNotifyRegister better?

Dmitry