Notification / callback when a device is enabled or disabled?

Hello,

I’m interested to know if there’s any way I can detect
programmatically in a user mode application when devices are enabled
or disabled (either via Device Manager in Windows or via the Devcon
DDK example application).

At the moment, the only way I can see of doing it is to periodically
iterate through the devices I’m interested in and call
CM_Get_DevNode_Status_Ex, examining the values returned in its first
and second arguments (ULONG status, ULONG problem).

Instead of doing this expensive periodic polling, I would like to be somehow:

  • register a callback,
  • receive and act on a notification event / message
    whenever a device status is changed.

Device Manager seems like it does something like this - as it updates
immediately if I enable or disable any device in the Devcon DDK
example application.

So I’m wondering if anyone can help me to do this in my user mode application.

Many thanks in advance for any help or pointers.

HP

Hello,

Take a look at RegisterDeviceNotification() or WM_DEVICECHANGE.

Andrei

HP wrote:

Hello,

I’m interested to know if there’s any way I can detect
programmatically in a user mode application when devices are enabled
or disabled (either via Device Manager in Windows or via the Devcon
DDK example application).

At the moment, the only way I can see of doing it is to periodically
iterate through the devices I’m interested in and call
CM_Get_DevNode_Status_Ex, examining the values returned in its first
and second arguments (ULONG status, ULONG problem).

Instead of doing this expensive periodic polling, I would like to be somehow:

  • register a callback,
  • receive and act on a notification event / message
    whenever a device status is changed.

Device Manager seems like it does something like this - as it updates
immediately if I enable or disable any device in the Devcon DDK
example application.

So I’m wondering if anyone can help me to do this in my user mode application.

Many thanks in advance for any help or pointers.

HP


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Ignorance more frequently begets confidence than does knowledge.
— Charles Darwin


This message was scanned for spam and viruses by BitDefender.
For more information please visit http://www.bitdefender.com/

Look up RegisterDeviceNotification in the Platform SDK dox (and read the
remarks etc carefully!)

/simgr

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of HP
Sent: Wednesday, August 03, 2005 10:42 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Notification / callback when a device is enabled or
disabled?

Hello,

I’m interested to know if there’s any way I can detect
programmatically in a user mode application when devices are enabled
or disabled (either via Device Manager in Windows or via the Devcon
DDK example application).

At the moment, the only way I can see of doing it is to periodically
iterate through the devices I’m interested in and call
CM_Get_DevNode_Status_Ex, examining the values returned in its first
and second arguments (ULONG status, ULONG problem).

Instead of doing this expensive periodic polling, I would like to be
somehow:

  • register a callback,
  • receive and act on a notification event / message
    whenever a device status is changed.

Device Manager seems like it does something like this - as it updates
immediately if I enable or disable any device in the Devcon DDK
example application.

So I’m wondering if anyone can help me to do this in my user mode
application.

Many thanks in advance for any help or pointers.

HP


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com