USB event notifications

  • Thread starter Thread starter Ross
  • Start date Start date
R

Ross

Hello,
I'm new to .NET development in general, and I can't seem to find the
answers I need anywhere else. Is there a way in the compact framework
to detect the insertion/removal of a USB memory stick? I have C# code
which needs to inform other modules of these events (specifically flash
memory devices; I'm not interested in other USB device insertions). I
also need to be able to determine the path to the device (assuming I
can still treat it as a regular drive) and perform read/write
operations.

I've seen this question posted on other groups, but they seem to all
have answers based on the use of WMI and the System.Management API of
the full .NET framework. Am I right in saying that this doesn't exist
for the compact framework?

Any answers, links to code samples, other discussions or documentation
would be greatly appreciated.

Thanks,
Ross
 
You have to register for device notifications, if that's supported in your
version of the OS, which you forgot to specify. These notifications are
sent via point-to-point message queues. What you're looking for is a
device-mount notification. OpenNETCF has a point-to-point message queue
class (and you can look at the network code to see a sample of its use). I
don't have any USB drives laying around my office, but you can probably find
the right GUID for mount notifications in the .h files from your device's
SDK (which you also didn't specify).

Paul T.
 
Back
Top