Click here to Skip to main content
15,851,711 members
Please Sign up or sign in to vote.
4.47/5 (9 votes)
Hello
I am doing computer engineering and i needed some guidance
regarding my project.
1st of all i want to know whether it is possible to disable usb ports
and CD rom "POWER" through VC++.
If yes then could you please guide me on it?
Thanks
Posted
Updated 21-Mar-16 2:06am
Comments
[no name] 16-Dec-11 10:07am    
All solutions I have seen here are OK! (Just OK!), because user (like us) can easily manipulate registry. If you are playing with Power User, s/he will beat you!
Philippe Mori 21-Mar-16 12:21pm    
This is very suspicious....

I don't know about removing power but you can lock volumes with DeviceIoControl() with the FSCTL_LOCK_VOLUME which means that your process has exclusive access to that volume. Take a look at the documentation here. You could do this with the CD drive.

You can disable USB ports from the registry (which can be done programatically); take a look at this article for more info.

Hope this helps,
--Perspx

 
Share this answer
 
Comments
[no name] 16-Dec-11 10:08am    
DeviceIoControl solution is good my 5! But other is easy to hack.
ameyakoshti wrote:
1st of all i want to know whether it is possible to disable usb ports


To disable USB ports, check this[^]. You have to programatically access the registry and set the key.

ameyakoshti wrote:
and CD rom "POWER" through VC++.

I hope someone else will shed light on this. [rolleyes]

Regards,
Jijo.

 
Share this answer
 
 
Share this answer
 
Comments
[no name] 16-Dec-11 10:07am    
Modifying register is simple, so anyone can do this.
I found a way to disable the CD ROM using regedit. Now I am not sure how you can use it in VC++ but you can atleast havea look at the way of disabling it through regedit

SQL
To Disable CD-Rom
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CDRom
Double Click on AutoRun and change the value to 0
This will stop it from automatically starting.
If you double click on start and change the Value to 0, it should disable it.



Also I found the following link where there is a discussion and a zip file which explains how to disable CD ROM using VB.NET. Ma be that will also of some help.

http://jo0ls-dotnet-stuff.blogspot.com/2009/01/enabledisable-device-programmatically.html[^]

Hope this was helpful.

--
AJ
 
Share this answer
 
C++
Floppy = CreateFile("\\\\.\\A:", GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL );

if( hFloppy != INVALID_HANDLE_VALUE )
{
    bRes = DeviceIoControl( hFloppy, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &dummy, NULL );
    if( !bRes )
    {
        CloseHandle( hFloppy );
        hFloppy = INVALID_HANDLE_VALUE;
    }
}
 
Share this answer
 
v2


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900