none
Acticate / deactivate USB-Port during runtime passible? RRS feed

  • Question

  • I have a WinEC2013 target with two USB-ports. How can I disable during runtime the automatic detection, if a USB-device (mouse, Keyboard, USB-stick, ..) is connected?

    Can I then re-enable it again, if needed in this LifeCycle?

    Is it possible to disable for example only the automatic detection from a USB-stick, so that the mouse or Keyboard detection still works?

    Can I do it only for one USB-port only, or if disabled, then for both of my available ports?

    I expect, that this is possible via the registry. But who knows the keys and values?

    Thanks for your help.


    Wednesday, February 25, 2015 9:24 AM

Answers

  • I do this in Windows CE 6.0 and I would expect that it works the same or similar in WEC2013.  When a USB device is connected, the registry is searched to determine if there are entries that match the characteristics for the device.  If there is a match, then the driver in the matching registry entry is loaded.   A USB driver can be prevented from loading by removing appropriate registry entries and can be re-enabled by adding the entries back.  The main limitation is that this process only occurs when USB devices are connected or disconnected.  I have used this approach in CE 4.0, 5.0 and 6.0 and it works great.
    Wednesday, February 25, 2015 3:51 PM
  • I found the relevant keys in the common.reg. I used for USB-mouse:

    [HKEY_LOCAL_MACHINE\Drivers\HID\LoadClients\Default\Default\1_2\Mouse]
       "DLL"="MOUHID.DLL"

    For USB-keyboard:

    [HKEY_LOCAL_MACHINE\Drivers\HID\LoadClients\Default\Default\1_6\Keyboard]
       "DLL"="KBDHID.DLL"

    For USB-stick:

    [HKEY_LOCAL_MACHINE\Drivers\USB\LoadClients\Default\Default\8\Mass_Storage_Class]
       "DLL"="USBMSC.DLL"

    When removing or adding this values in the registry on the target the devices will not work or start to work when connected. This changes works only when (re-)connecting the devices, not on the fly!

    Friday, February 27, 2015 10:21 AM

All replies

  • I do this in Windows CE 6.0 and I would expect that it works the same or similar in WEC2013.  When a USB device is connected, the registry is searched to determine if there are entries that match the characteristics for the device.  If there is a match, then the driver in the matching registry entry is loaded.   A USB driver can be prevented from loading by removing appropriate registry entries and can be re-enabled by adding the entries back.  The main limitation is that this process only occurs when USB devices are connected or disconnected.  I have used this approach in CE 4.0, 5.0 and 6.0 and it works great.
    Wednesday, February 25, 2015 3:51 PM
  • Hey that sounds nice and seems to be the right path then, but to make it complete, can you perhaps give me an example which key you have removed or added.

    Can I distinguish between a mouse or a keyboard or a USB-stick?

    Thanks.

    Thursday, February 26, 2015 5:18 AM
  • You can use the power manager to power down the driver, if you driver is power manager aware.

    Bruce Eitman (eMVP) Senior Engineer Bruce.Eitman AT Eurotech DOT com My BLOG http://geekswithblogs.net/bruceeitman Eurotech Inc. www.Eurotech.com

    Thursday, February 26, 2015 1:11 PM
    Moderator
  • I found the relevant keys in the common.reg. I used for USB-mouse:

    [HKEY_LOCAL_MACHINE\Drivers\HID\LoadClients\Default\Default\1_2\Mouse]
       "DLL"="MOUHID.DLL"

    For USB-keyboard:

    [HKEY_LOCAL_MACHINE\Drivers\HID\LoadClients\Default\Default\1_6\Keyboard]
       "DLL"="KBDHID.DLL"

    For USB-stick:

    [HKEY_LOCAL_MACHINE\Drivers\USB\LoadClients\Default\Default\8\Mass_Storage_Class]
       "DLL"="USBMSC.DLL"

    When removing or adding this values in the registry on the target the devices will not work or start to work when connected. This changes works only when (re-)connecting the devices, not on the fly!

    Friday, February 27, 2015 10:21 AM