开发者

How to get information about network adapters in c++?

How to get information about all n开发者_开发知识库etwork 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜