Many thanks for the response - yes, this does make sense.
In my previous message, I mentioned that I set a timer to wait for a few
seconds after a device is plugged in before sending a request to disable the
device. By doing this, the disabling took place immediately. If I didn't wait
for a few seconds, then it would take 30 seconds or more.
Ideally, I would prefer not to use a timer to wait for a specific amount of
time for the newly-added device to be fully installed - as I appreciate that
this may vary from computer to computer, and maybe even from device to device.
Does anyone know a way whereby I can detect / get a notification when a
device is fully initialised (i.e. when the special thread for the install has
completed) after being plugged in?
(at which time, I would be guaranteed a “safe” time to request disabling and
get an immediate response.)
The WM_DEVICECHANGE message with DBT_DEVICEARRIVAL wParam seems to tell me
the instant it is plugged in, but before it is all initialised and safe to
send to a disable request.
Thanks again for any ideas / comments.
JP
"Daniel Whitaker [MSFT]" wrote:
> Greetings,
>
> Interesting project
Some of this is a bit curious, but I do know that
> there is a difference when you are adding a new device/enabling for the
> first time. Windows creates a special thread for the install and will not
> allow other "PNP" events to occur until it completes. If it does not
> succeed, you will normally see a "there was a problem with your hardware"
> bubble. But otherwise there can be a delay for the next "PNP" event. They
> sort of line up in a row and then are sent through this thread pipe. There
> is a timeout value of up to 2 minutes, but generally it seems to be about
> 30 seconds to a minute.
>
> Any other time, the function call is taken care of immediately. I would
> think that calling the ClassInstaller when the thread is active would
> probably cause a delay because of the install thread. Does that make any
> sense?
>
> Daniel Whitaker
> DDK Support Team
>
> This posting is provided "AS IS" with no warranties, and confers no rights
>
>
>