Re: how can i control NIC on Windows




casper wrote:
hi, everyone

i need to change the work mode of NIC dynamically, such as link speed or
duplex mode, i have no idea about how to implement this, would anyone have
such programming experience give me some hints, thanks a lot:)


There's not a generic way to do that, although you might find
documented IOCTLs and or registry entries for a particular driver, or
perhaps even a command line utility. Talk to your NIC vendor.

If you only need to do this for one device, you may want to consider
one of the scripting tools that would allow you to open the Control
Panel, Network... and just script the changes you want. That at least
will be reasonably safe.

If you want to do that programmatically, you best bet (although
certainly not 100% safe) is to find the registry entries for the NIC in
question (should be under HKLM\SYSTEM\CurrentControlSet someplace), and
determine the changes you want to make. Then when you want to
implement the change do a "NET STOP xxx", update the registry, and do a
"NET START xxx". You can program the NET STOP/START function (see the
service control manager stuff) if you want too, although just executing
it via the shell works too. Again, you're poking at the undocumented
internals here, so there are certainly no guarantees.

I'm assuming this is not your own device - if it is, you just need to
implement an appropriate set of IOCTLs in your NDIS miniport.

.