12

I have an application (.Net Compact Framework 3.5) running on a Windows Mobile 6.1 device and I want to detect when the USB connection changes (either something connects or disconnects).

I was originally using the SystemProperty.CradlePresent property to trigger an event but I am wondering if this only works if the device connecting has ActiveSync? I will be receiving a connection via USB from a Linux device that does not have ActiveSync running on it.

Can I still use SystemProperty.CradlePresent to detect the connect/disconnect from the USB? Or do I need to explore other options to detect the USB event? Thanks.

Chris B
  • 161
  • 2
  • 6
  • 1
    You're connecting a Linux device to a WM6 device via USB? USB has a master/slave architecture; 2 _devices_ can't communicate directly but must do so via the _host_. – MSalters Mar 24 '11 at 09:20
  • The WM6 device is just receiving data from the Linux device via a Socket connection. I am just trying to determine if I can use the SystemProperty I mentioned above to detect when the Linux device is connected via USB. – Chris B Mar 24 '11 at 13:34
  • I'm with MSalters. It doesn't sound like you fully understand USB. You're going to be a slave device. If that's turned into some form of socket, then are we to assume you've got a driver that will do this? Does teh driver have any notifications? – ctacke Mar 24 '11 at 15:22
  • 1
    Well, if you have ActiveSync on WM6, then you'll have an RNDIS socket driver. But the RNDIS stack is the remote part of the NDIS stack that's expected to run on the USB master. So you not only have an issue at USB bus level, but also at the NDIS level. – MSalters Mar 25 '11 at 16:47

2 Answers2

2

Perhaps this previous question of mine may help:

How can I detect a USB disconnect event? (Windows, .NET C# application)

I ended up listening for and handling WM_DEVICECHANGE events. They are specified here: http://msdn.microsoft.com/en-us/library/aa363480(VS.85).aspx

Unfortunately I don't have a copy of the source code anymore so my memory on it is a bit hazy. I don't know if this solution applies in your context.

Community
  • 1
  • 1
Jon
  • 1,379
  • 1
  • 12
  • 32
1

Check this out, you might be able to grab part of the source code. Its written in C# with a GUI. Keep in mind every time you have a program running that is checking for new USB drives, it will take up memory and CPU so you might want to tone down the intervals at which it checks and then supply a "refresh" button for impatient users.

llk
  • 2,501
  • 7
  • 36
  • 43
  • The method described in that article uses event handlers, not a polling method. It should not be CPU or memory intensive. – Jon Apr 06 '11 at 20:53