Solved

Enable / Disable USB without using the registry

Posted on 2008-06-10
1
2,303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 250 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

730 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