I have an application written in C# that needs to retrieve information like IP address, subnet mask from a disconnected network adapter.
I've tried using various methods such as WMI and the .NET NetworkAdapter class but they don't return any useful data when the network adapter is disconnected. I'm pretty sure Windows keeps this information somewhere, since I can apply network settings using netsh and it appears correctly in the Control Panel.
One thing that worked for me in XP was to parse the output of the netsh
tool and it would return information even for a disconnected adapter. However, this doesn't seem to work on Windows 7.
Win XP output:
Configuration for interface "Local Area Connection 5"
DHCP enabled: No
IP Address: 169.254.0.128
SubnetMask: 255.255.255.0
InterfaceMetric: 0
Win7 output:
Configuration for interface "Local Area Connection 2"
DHCP enabled: No
InterfaceMetric: 5
Any ideas?