1
votes

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?

1
Have you browsed through the SetupAPIs documented on MSDN? What other google searches have you performed?Χpẘ
Unfortunately I'm not very familiar with the SetupAPI and the documentation is quite voluminously. I googled a lot, but most of the suggestions are .NET or rather Scripting, or make use of functions that are not available in XP. Currently I think about to use SetupAPI to enumerate all netowrk interfacaes and find something that matches the information from Win32_NetowrkAdapert. Any suggestions?.Willy K.
I just googled "setupapi get network adapter index" and the first result was on SO titled how-to-get-network-adapter-index. The accepted answer uses .Net NetworkInterface and C#. .NET and C# are both supported on XP, right?Χpẘ
As stated in the heading my question is about doing that in C++, not C# or C# .NET.Willy K.
C++ can be used to invoke .NET APIs, using managed extensions.Χpẘ

1 Answers

0
votes

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