Hello all,

Can someone point me in the direction to some c# code for auto-detecting
when a user inserts an sd card into a device?

--
Noble D. Bell
www.noblesoftware.com

Re: Auto-detecting SD card insertion by Christopher

Christopher
Mon Mar 10 20:24:01 CDT 2008

Hi,

"Noble Bell" <NobleBell@discussions.microsoft.com> wrote in message
news:8E41931C-96BC-46CB-9D47-D51B0975D54E@microsoft.com...
> Can someone point me in the direction to some c# code for auto-detecting
> when a user inserts an sd card into a device?

One technique would be to P/Invoke a function called
RequestDeviceNotifications (documented on MSDN at
http://msdn2.microsoft.com/en-us/library/ms919831.aspx).

The OpenNETCF library has a pre-made wrapper around this API within the
OpenNETCF.Net.DeviceStatusMonitor class. See the documentation at
http://www.opennetcf.com/library/sdf/html/07b50991-2568-a408-0be0-75d435285e09.htm

For the first parameter to the DeviceStatusMonitor constructor you might
like to pass in DeviceStatusMonitor.STORE_MOUNT_GUID which will notify you
whenever a new storage device becomes available to the storeage manager.

Here's an example demonstrating the use of this API.

using OpenNETCF.Net;

DeviceStatusMonitor monitor = new
DeviceStatusMonitor(DeviceStatusMonitor.STORE_MOUNT_GUID, false);
monitor.DeviceNotification += new
DeviceNotificationEventHandler(monitor_DeviceNotification);
monitor.StartStatusMonitoring();

void monitor_DeviceNotification(object sender, DeviceNotificationArgs e)
{
MessageBox.Show(e.DeviceName, e.DeviceAttached ? "attached" :
"disconnected");
}

Hope this helps,
Christopher Fairbairn



Re: Auto-detecting SD card insertion by NobleBell

NobleBell
Tue Mar 11 11:37:05 CDT 2008

Thank you Christopher. That did the trick.

--
Noble D. Bell
www.noblesoftware.com



"Christopher Fairbairn" wrote:

> Hi,
>
> "Noble Bell" <NobleBell@discussions.microsoft.com> wrote in message
> news:8E41931C-96BC-46CB-9D47-D51B0975D54E@microsoft.com...
> > Can someone point me in the direction to some c# code for auto-detecting
> > when a user inserts an sd card into a device?
>
> One technique would be to P/Invoke a function called
> RequestDeviceNotifications (documented on MSDN at
> http://msdn2.microsoft.com/en-us/library/ms919831.aspx).
>
> The OpenNETCF library has a pre-made wrapper around this API within the
> OpenNETCF.Net.DeviceStatusMonitor class. See the documentation at
> http://www.opennetcf.com/library/sdf/html/07b50991-2568-a408-0be0-75d435285e09.htm
>
> For the first parameter to the DeviceStatusMonitor constructor you might
> like to pass in DeviceStatusMonitor.STORE_MOUNT_GUID which will notify you
> whenever a new storage device becomes available to the storeage manager.
>
> Here's an example demonstrating the use of this API.
>
> using OpenNETCF.Net;
>
> DeviceStatusMonitor monitor = new
> DeviceStatusMonitor(DeviceStatusMonitor.STORE_MOUNT_GUID, false);
> monitor.DeviceNotification += new
> DeviceNotificationEventHandler(monitor_DeviceNotification);
> monitor.StartStatusMonitoring();
>
> void monitor_DeviceNotification(object sender, DeviceNotificationArgs e)
> {
> MessageBox.Show(e.DeviceName, e.DeviceAttached ? "attached" :
> "disconnected");
> }
>
> Hope this helps,
> Christopher Fairbairn
>
>
>

Re: Auto-detecting SD card insertion by srhartone

srhartone
Wed Mar 12 17:54:03 CDT 2008

I find that API a bit flakey, sometimes it doesn't fire when re-inserting the
card!
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


"Christopher Fairbairn" wrote:

> Hi,
>
> "Noble Bell" <NobleBell@discussions.microsoft.com> wrote in message
> news:8E41931C-96BC-46CB-9D47-D51B0975D54E@microsoft.com...
> > Can someone point me in the direction to some c# code for auto-detecting
> > when a user inserts an sd card into a device?
>
> One technique would be to P/Invoke a function called
> RequestDeviceNotifications (documented on MSDN at
> http://msdn2.microsoft.com/en-us/library/ms919831.aspx).
>
> The OpenNETCF library has a pre-made wrapper around this API within the
> OpenNETCF.Net.DeviceStatusMonitor class. See the documentation at
> http://www.opennetcf.com/library/sdf/html/07b50991-2568-a408-0be0-75d435285e09.htm
>
> For the first parameter to the DeviceStatusMonitor constructor you might
> like to pass in DeviceStatusMonitor.STORE_MOUNT_GUID which will notify you
> whenever a new storage device becomes available to the storeage manager.
>
> Here's an example demonstrating the use of this API.
>
> using OpenNETCF.Net;
>
> DeviceStatusMonitor monitor = new
> DeviceStatusMonitor(DeviceStatusMonitor.STORE_MOUNT_GUID, false);
> monitor.DeviceNotification += new
> DeviceNotificationEventHandler(monitor_DeviceNotification);
> monitor.StartStatusMonitoring();
>
> void monitor_DeviceNotification(object sender, DeviceNotificationArgs e)
> {
> MessageBox.Show(e.DeviceName, e.DeviceAttached ? "attached" :
> "disconnected");
> }
>
> Hope this helps,
> Christopher Fairbairn
>
>
>

Re: Auto-detecting SD card insertion by Christopher

Christopher
Wed Mar 12 18:13:39 CDT 2008

Hi,

"Simon Hart [MVP]" <srhartone@yahoo.com> wrote in message
news:6774A38F-B686-4F64-B69A-82414A60616D@microsoft.com...
>I find that API a bit flakey, sometimes it doesn't fire when re-inserting
>the card!

I haven't personally used the API for SD card detection.

I do however use it to detect the presence of a device being inserted into
our PDA. Our custom device driver written to control the device has the
nesscary settings to advertise itself via this API. It works well in that
scenario.

Thanks,
Christopher Fairbairn.



Re: Auto-detecting SD card insertion by srhartone

srhartone
Thu Mar 13 04:24:00 CDT 2008

Sounds interesting. I tend to find this flakeyness takes place on WM5 devices
pre WM5 are OK. Not tried WM6 much, but we have a whole bunch of new WM6
devices coming in soon so will test those.

This device driver, was it written in unmanaged code?
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


"Christopher Fairbairn" wrote:

> Hi,
>
> "Simon Hart [MVP]" <srhartone@yahoo.com> wrote in message
> news:6774A38F-B686-4F64-B69A-82414A60616D@microsoft.com...
> >I find that API a bit flakey, sometimes it doesn't fire when re-inserting
> >the card!
>
> I haven't personally used the API for SD card detection.
>
> I do however use it to detect the presence of a device being inserted into
> our PDA. Our custom device driver written to control the device has the
> nesscary settings to advertise itself via this API. It works well in that
> scenario.
>
> Thanks,
> Christopher Fairbairn.
>
>
>

Re: Auto-detecting SD card insertion by Christopher

Christopher
Thu Mar 13 05:22:49 CDT 2008

Hi,

Simon Hart [MVP] wrote:
> Sounds interesting. I tend to find this flakeyness takes place on WM5 devices
> pre WM5 are OK. Not tried WM6 much

Thanks for that info. It's always good to find out these kinds of
things, as they can suck up a lot of time if you only discover them late
into a debugging session...

> This device driver, was it written in unmanaged code?

Yes it's written in C. It's for a custom PCMCIA based camera module we
have developed with medical applications in mind -
http://www.aranzmedical.com/

Thanks,
Christopher Fairbairn