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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

disabling a device programmaticaly

Reply to Message Icon

Name: rizwan farooq
Date: September 2, 2007 at 23:49:08 Pacific
OS: windows xp
CPU/Ram: 512 ram
Product: 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



Sponsored Link
Ads by Google

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

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.



0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: disabling a device programmaticaly

Programming a device drivers www.computing.net/answers/programming/programming-a-device-drivers/1002.html

Wrting a device driver... www.computing.net/answers/programming/wrting-a-device-driver/13774.html

Loopback Device www.computing.net/answers/programming/loopback-device/1218.html