Computing.Net > Forums > Programming > disabling a device programmaticaly

disabling a device programmaticaly

Reply to Message Icon

Original Message
Name: rizwan farooq
Date: September 2, 2007 at 23:49:08 Pacific
Subject: disabling a device programmaticaly
OS: windows xp
CPU/Ram: 512 ram
Model/Manufacturer: dell
Comment:

hello to all the c# gurus
my problem is that i want to enable and disable a devices in device manager using c#
is there any body that can help me
thanx in advance

yahoo


Report Offensive Message For Removal


Response Number 1
Name: Razor2.3
Date: September 3, 2007 at 19:12:03 Pacific
Reply: (edit)

The way I see it, you have two options.

1) Just modify the registry directly. On the WinNT line (at least XP-), you'd find the hardware in HKLM\SYSTEM\CurrentControlSet. In terms of difficulty, it's pretty basic. .NET even has its own Registry class you can use. For reference, here's what happened to my registry when I disabled my DVD-ROM:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\{1186654d-47b8-48b9-beb9-7df113ae3c67}\##?#IDE#CdRomPHILIPS_CDRW#DVD_SCB5265________________TD15____#5&f45c574&0&0.0.0#{1186654d-47b8-48b9-beb9-7df113ae3c67}\#\Control]
"Linked"=dword:00000001 -> 0

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\{1186654d-47b8-48b9-beb9-7df113ae3c67}\##?#IDE#CdRomPHILIPS_CDRW#DVD_SCB5265________________TD15____#5&f45c574&0&0.0.0#{1186654d-47b8-48b9-beb9-7df113ae3c67}\Control]
"ReferenceCount"=dword:00000001 -> 0

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\##?#IDE#CdRomPHILIPS_CDRW#DVD_SCB5265________________TD15____#5&f45c574&0&0.0.0#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\#\Control]
"Linked"=dword:00000001 -> 0


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\##?#IDE#CdRomPHILIPS_CDRW#DVD_SCB5265________________TD15____#5&f45c574&0&0.0.0#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\Control]
"ReferenceCount"=dword:00000001 -> 0

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ServiceCurrent]
@=dword:00000015 -> 14

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE\CdRomPHILIPS_CDRW/DVD_SCB5265________________TD15____\5&f45c574&0&0.0.0\Control]
"ActiveService"="redbook"
"DisableCount"=dword:00000000 -> 1

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0001\System\CurrentControlSet\Enum\IDE\CDROMPHILIPS_CDRW/DVD_SCB5265________________TD15____\5&F45C574&0&0.0.0]
"CSConfigFlags"=dword:00000000 -> 1

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Enum\IDE\CDROMPHILIPS_CDRW/DVD_SCB5265________________TD15____\5&F45C574&0&0.0.0]
"CSConfigFlags"=dword:00000000 -> 1

2) Your other option would be to use API calls. Sure, using API calls in C# / VB is a royal pain, but it's bound to be more compatible, as you don't need to care about where MS is keeping its hardware information.



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: disabling a device programmaticaly

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge