Discussion:
How do detect USB device arrive/remove in the HealthVault structur
(too old to reply)
orson
2010-09-30 02:25:03 UTC
Permalink
Hi all,

I am using the FabrikamBloodPressure sample to add my own code, but there
are some function need to complete (e.g., OnDeviceArrival).

I had try and search some solution, but they don't work well or i can't find
the place to add in my code (e.g., RegisterDeviceNotification)

And where are some other discussion.
<a
href="http://social.msdn.microsoft.com/Forums/en-US/healthvault/thread/aa7d26ce-a044-401f-bdc4-42d1416e6839">Thread 1</a>

<a
href="http://social.msdn.microsoft.com/Forums/en/healthvault/thread/a14a1467-dcda-4300-91b9-b08b93286aa4">Thread 2</a>

Is there any other solution?

Thanks a lot.
Pavel A.
2010-09-30 15:38:35 UTC
Permalink
Post by orson
Hi all,
I am using the FabrikamBloodPressure sample to add my own code, but there
are some function need to complete (e.g., OnDeviceArrival).
I had try and search some solution, but they don't work well or i can't find
the place to add in my code (e.g., RegisterDeviceNotification)
And where are some other discussion.
<a
href="http://social.msdn.microsoft.com/Forums/en-US/healthvault/thread/aa7d26ce-a044-401f-bdc4-42d1416e6839">Thread
1</a>
<a
href="http://social.msdn.microsoft.com/Forums/en/healthvault/thread/a14a1467-dcda-4300-91b9-b08b93286aa4">Thread
2</a>
Is there any other solution?
Thanks a lot.
RegisterDeviceNotification() usually works well.
As to the place where it can be added, you usually do this just after you
get the
prerequisites - a window handle or service handle.
If you use a window handle, you get to have a message loop somewhere to
handle the WM_DEVICECHANGE.

Instead of using the arrival/removal notifications, you can find currently
attached devices using SetupDiGetClassDevs()

(but it still is recommended to detect the removal using notification, so
the app will promptly close the removed device's handle).

Regards,
-- pa

Loading...