?
Solved

Enable / Disable USB without using the registry

Posted on 2008-06-10
1
Medium Priority
?
2,343 Views
Last Modified: 2013-12-14
i would like to Enable and Disable USB ports. I have read that it can be done by changing the registry value but the problem is you need to restart or remove and attached again the usb device... i nedd to disable and enable it on the time the usb is attached.

i have read that it can be done using the SetupDiCallClassInstaller, but i dont know how to use it and perform it in mfc..is there anybody who can give some sample about this matter.

many thanks
0
Comment
Question by:haroldxious
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 750 total points
ID: 21756478
See http://www.codeproject.com/KB/system/HwDetect.aspx ("Detecting Hardware Insertion and/or Removal"), especially this section:

--------------------------------------------->8---------------------------------

Disable a device

Suppose you have the correct HDEVINFO and SP_DEVINFO_DATA (actually, we save the dbcc_name as the tree node extra data and retrieve that data when we right click on the device icon and then call SetupDiGetClassDevs and SetupDiEnumDevicInfo), the flow to disable a device is as follows:

   1. Setup the SP_PROPCHANGE_PARAMS structure properly
   2. Call SetupDiSetClassInstallParams() and pass-in the SP_PROPCHANGE_PARAMS structure
   3. Call SetupDiCallClassInstaller() with DIF_PROPERTYCHANGE

--------------------------------------------->8---------------------------------

The article comes with full source code.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question