0
votes

I was unable to find a Win32 API to modify network interface properties. By "network interface properties" I mean properties, which can be set using the "network connections" panel in the System control panel manually or using "netsh interface" from the command line.

In particular, I want to modify:

  • The network connection name (e.g. "Local Area Connection #2"
  • The IPv4 network interface metric (which is "automatic" by default)

To identify the network adapter, I have a device instance ID of the PnP device manager (e.g. "ROOT\NET\0000"). I also have an instance of a SetupAPI SP_DEVINFO_DATA structure. I can probably also query the NetCfgInstanceId using SetupAPI.

Is there a Win32 API which does what I want? I don't want to use WMI. Target platforms are Windows 7 x64 or newer.

1
"I don't want to use WMI." -- why not? That would be the obvious way to solve this problem. - Roger Lipscombe
Unfortunately, it is not guaranteed that the WMI services are running - Cybran

1 Answers

1
votes

Problem 1: Try using INetworkConnection::Rename. In order to get the connection you want, you have to use INetSharingManager to enumerate all connections. Do an iteration to find the one you need to change.