Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C++/CLI C MFC ATL WTL STL
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 22-Aug-08 3:09am
Comments
Pranit Kothari at 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!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

  Permalink  
Comments
Pranit Kothari at 16-Dec-11 10:08am
   
DeviceIoControl solution is good my 5! But other is easy to hack.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Comments
Pranit Kothari at 16-Dec-11 10:07am
   
Modifying register is simple, so anyone can do this.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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
 
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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

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;
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

//Disable Usb in c# 
Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord);
 
//enable USB storage...in c#
Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 3, Microsoft.Win32.RegistryValueKind.DWord);
  Permalink  
Comments
Wes Aday at 17-Jul-12 9:55am
   
Do you seriously think that the OP has been waiting for 4 years when the question has already been answered?
  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 11 Dec 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100