简体   繁体   中英

How to re-enable a disabled network connection in Windows XP using C++?

I found this article at SO that tells how to enable/disable a network adpter using the SetupAPI. This works fine so far. The problem is that I could not find a way to get the device index for network connections (adapters) that have been disabled in Windows XP .

I have:

  • The list of GUIDs (from HKLM\\SOFTWARE\\Microsoft\\Windows NT\\Netcards)
  • Everything from Win32_NetworkAadapter that is supported in Windows XP

I tried without success:

  • GetIfTable() - disabled adapters are not present in the table
  • Win32_NetworkAdapter::InterfaceIndex is not supported in XP
  • Win32_NetworkAdapter::Enable()/Disable() is not supported in XP

What else can I do to obtain the device index or to get a disabled network adapter re-eabled again?

Based on my experience building my Network Connection Guard tool the easiest way to do this is with the netsh command, not APIs. My example is C# so I used System.Diagnostics.Process but in your case I believe you could use ShellExecute() .

Also see this answer on SO Programmatically disable/enable network interface

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM