472,378 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 software developers and data experts.

How to use .NET framework to toggle the power on a USB-powered dev


We have a C#.NET win-forms application that talks to a device plugged into
the USB port. Sometimes when severe communications interruptions occur, such
as from a burst of ESD electricity, we need to toggle the power on that
device in order to bring it back to life.

We can do this by unplugging the usb cable from the PC, obviously, but our
program needs to recover without manual intervention.

Can anyone tell me how to toggle the power off, then back on, to a
particular USB port, programmatically? If I can do this via the .NET
framework, that would be best, but if I have to I can call win32 api calls...

This is critical as it is needed to pass an agency certification test, and
is delaying a product launch. Any help is much appreciated!

Jul 21 '05 #1
3 15550
Hi Robb,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to turn off a certain usb
device and turn it back on. If there is any misunderstanding, please feel
free to let me know.

As far as I know, USB is a hardware bus and as such not directly exposed to
user-mode (Win32) applications (or even .NET). Only Windows device-drivers
do control the USB. So you have to get a driver from manufacturer.

So if you connect a printer with USB, use the Win32/.NET printer-API. Or if
you connect a modem with USB, use the Win32 serial-API. Or if you connect
an imaging device (camera/scanner), use TWAIN/WIA.

If you want to design your own external, USB compliant hardware, you have
to understand the USB bus protocol and implement a controller chip. Then on
Windows side, you have to write your own device driver with the Windows
DDK. Sure there are OEM kits making all this easier.

Please visit the following sites for more information.


In Windows, you can use Win32_USBController to power off a certain device.
For more information, please check the following link:


Besides posting here, you can also post in microsoft.public.ddk. There are
more professionals in that group to help you with this issue. HTH.

Kevin Yu
"This posting is provided "AS IS" with no warranties, and confers no

Jul 21 '05 #2

We do have a driver we are using, which is from Texas Instruments. My
question is how do I use the .NET framework to access that driver and tell it
to reset itself? The Win32 serial API seems to have some of the correct
commands in it (thanks) but I'm not sure how to use them to tell a specific
device on a specific COM port to reset. I know the COM port #, and I know
the name of the driver..how do I say "reset yourself"? Even if I could reset
that port it would accomplish what I need.

Basically I am trying to do one of two things:

1. Ideally, tell windows to stop sending power to a certain port. This
will cause the USB device on that port to see the power loss and reset itself.

2. If that is not possible, another idea is to just "reset" the port in
question. If ai Can do that, it might interupt the flow of USB traffic to
the device long enough for the device to detect it, and reset itself.

Can you tell me if either of these is possible via the .NET framework?

Jul 21 '05 #3
Hi Robb,

As far as I know, we cannot power off a certain USB port. However, we can
tell a certain USB device to reset itself if the device's driver supports
this operation. Based on my research, there is a Reset method in
CIM_USBDevice class that can request a reset of the logical device. You can
check the following link for more information.


Since I'm not quite familiar with WMI, I suggest you post in
microsoft.public.win32.programmer.wmi newsgroup. It is a managed newsgroup.

If this can be done with WMI, the method can be called via .NET framework
through System.Management namespace. Here is an example of how to perform
this using .NET.



Kevin Yu
"This posting is provided "AS IS" with no warranties, and confers no

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Al Dykes | last post by:
I've just grabbed a PHP book and can deal with the syntax and now I need to decide to learn specific packages and features. Define "framework". What are the major framework flavors ? Under...
by: Stephane Belzile | last post by:
Is there a way I can detect in vb.Net the power has switched to a UPS unit in case of power failure? Thanks
by: Helge Jensen | last post by:
Having posted in microsoft.public.dotnet.framework.sdk and microsoft.public.dotnet.framework.wmi without receiving any response, I posthere on the off-chance that someone who isn't following those...
by: leegold2 | last post by:
I wondered if anyone would give me code- I think it would be easy, but I'm a complete newbie. What I want to do is to show many tables in a brief truncated format and then for each table offer the...
by: MLH | last post by:
Why is that? If I choose the tiny check boxes which are hard to hit with a mouse, it works fine. But option buttions, shich can be sized big enough for people with limited sight and dexterity...
by: Steven | last post by:
Can anyone tell me how to toggle the "Caps Lock" key? Thanks in advance
by: sksoule | last post by:
Hi, Can anyone please tell me how to toggle a nth bit. For example, I am having a variable which is of 8 bits. I want to toggle the nth bit. Regards, Santosh
by: Ole | last post by:
Hi, Is there a way to turn on/off the USB power switch from C#? Is it also possible to get a "short curcuit" event from the USB port? Thanks Ole
by: =?Utf-8?B?cmZsYXphcm8=?= | last post by:
Hi All, We are trying to build an automation utility to configure OS. May I ask for anyone who could help me find a way to automate in C# the processes below via WMI/API/Registry? Control...
by: swiftouch | last post by:
I'm getting an error message in FF2.0: document.getElementById(toggle) has no properties The goal of the script is, when I hover my mouse over an image, to make one div element visible while...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.