Enable/Diasble a network device programmatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to enable/disable a network device in C# but haven't found any
solutions. .Net Open Compact Framework only lets me manipulate Enabled/On
devices, say wireless network.

Is there any APIs or other ways I can use to accomplish this task? Thank you.

Minh
 
Thanks to Sergei and Paul.

That post seems to satisfy their problem, since it's a little simpler than
mine. This is their format:
[HKEY_LOCAL_MACHINE\Comm\NdisPower] <adapterName>=dword:00000004
This format allows them to simply delete/add the value dword out of the pair
to enable/disable.

This is what I have to add into [HKEY_LOCAL_MACHINE\Drivers\Active\53]
instead of :[HKEY_LOCAL_MACHINE\Comm\NdisPower] to activate the device:
[HKEY_LOCAL_MACHINE\Drivers\Active\53]
"Hnd"=dword:0073a7e0
"InterfaceType"=dword:00000008
"Key"="Drivers\PCMCIA\Texas_Instruments-ACX100-EE1D"
"Name"="NDS1:"
"PnpId"="Texas_Instruments-ACX100-EE1D"
"RegenumParms"=hex(7):\
53 00 63 00 6B 00 74 00 00 00 50 00 6E 00 70 \
00 49 00 64 00 00 00 52 00 65 00 67 00 65 00 \
6E 00 75 00 6D 00 50 00 61 00 72 00 6D 00 73 \
00 00 00 00 00

I can remove the device easily by deleting the key, but I won't be able to
enable it if I don't have the Dword value off hand, which is assigned
dynamically by the system when the driver is loaded. Do you have any
suggestions on that? Thanks again.

Minh
 
I got it! Thanks Paul.

I've got another problem: I happen to use the Adapter class from
OpenNETCF.Net. Some of its methods use pointers thus marked as unsafe.
Unsafe Build would spit an Authorization Exception (keys were open as
read-only) when I tried to write to the registry.. Is there any way to get
around that?

Minh
 
Back
Top