An application can register for device change notifications using RegisterDeviceNotification Function (Windows) API. When an application or service calls RegisterDeviceNotification, it also specifies the window that will receive the notification events. Services can specify a service status handle instead of a window handle. If a service specifies its service status handle, its service control handler will receive the notification events.
Using this API you can register to get the notifications when a network resource (disk) is mapped or deleted. You can use : net use <drive letter> <//server/share> to map a drive from the command line.
In windows Vista an onwards with UAC turn on an application registered for this notification does not get notified with WM_DEVICECHANGE if an administrator has mapped the drive or a drive has been mapped using admin command prompt. You don't even see the drive mapped in the windows explorer.
You see this behavior because drives are mapped per user basis see : INFO: Services and Redirected Drives. When UAC is turned on, users who are part of Administrator group login as Standard user. An application running under a user context can only receive notification if the drive is mapped in same user's logon session. Therefore when you map the drive from standard user's command prompt you get the notification.
To get the notification for the drives mapped using Administrator's command prompt you would need to elevate and run the application. However in that case application will not be able to get notifications for the drives mapped from standard user's command prompt.
Windows explorer cannot see the drives mapped by admin command prompt because it always runs non elevated. It is not possible to run the Windows explorer elevated.
How to make the program running as Administrator get WM_DEVICECHANGE when a user mapped a network device using Explorer?
@Roaman The best way is that, map the device in the Administrator contaxt, you may use an elevated command prompt and map the drive.