?
Solved

Enable / Disable USB without using the registry

Posted on 2008-06-10
1
Medium Priority
?
2,325 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 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

777 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