views:

100

answers:

2

How to get information about all network adapters in system? Name, Manufacturer, Location(PCI, slot2), Driver Version. Actually i retrieved Name and Manufacturer with WMI but i can't find Location and Driver version. I need only c++ solutions not MFC/clr. winapi function? wmi (missing something)? Also i need to retrieve .NET version on system.

+1  A: 

In reference to your second request: 'i need to retrieve .NET version on system'

This can be done via the Unmanaged Hosting API. If you are using .NET 4.0 then you can use the new ICLRMetaHost interface. The EnumerateInstalledRuntimes() function will give you all currently installed .NET runtimes.

You could also do this using WMI but it will require some more work. When installing .NET a WMI Win32_Product object is created. Using WMI Studio you can connect to root\CIMV2 (Windows 7), navigate to CIM_Product\Win32_Product, and view all WMI objects for all MSI installed applications. You will be able to find all installed instances of the framework there and determine how you want to identify them in code.

Just to mention what you can get from WMI with respect to the driver for your network adapter. I assume you are using the Win32_NetworkAdapter objects. The ServiceName property on that object is tied to the Name property of the Win32_SystemDriver object that represents the driver being used for that adapter. Win32_SystemDriver objects do have not version information but they do have paths to the actual file binary. For instance my wireless network adapter is using this driver, C:\Windows\system32\DRIVERS\athr.sys. Once you have the full driver path you may be able to get the version of the file via another mechanism.

linuxuser27
Nice, thank you a lot. I found .Net and systemDrivers via WMI. And now I only need to get to location of network adapter (PCI, slot3 ... ) if this information is available.
shake
A: 

I don't know if WMI exposes this or not, but the location information is obtained from the registry via the SetupAPI function SetupDiGetDeviceRegistryProperty with SPDRP_LOCATION_INFORMATION.

Luke