Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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 advanceyahoo

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 -> 12) 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.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |