From: orson on
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.
From: Pavel A. on
"orson" <orson(a)discussions.microsoft.com> wrote in message
news:463D83B5-D7E3-48F9-B358-0B859E681FC7(a)microsoft.com...
> 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