Network interface settings in embedded Windows XP

断了今生、忘了曾经 提交于 2019-12-23 21:45:54

问题


How can we get the network interface name (i.e. the one that appears in the "Network connections" dialog) given the device description (i.e. the string that appears in the "Device Properties -> Connect using:" textbox)?

We must do it in pure C/C++ language, or through some of the standard command line tools (e.g. netsh, ipconfig...), or a combination of both.

We CAN'T use the .NET API, because of deployment problems (the application must run on an XP embedded without .NET Framework).

The SDK API GetIfTable and GetIfEntry seem promising, but on our system all the MIB_IFROW fields are filled correctly, except the "wszName" one, that remains uninitialized.


回答1:


I was able to do this via the registry. Using GetAdaptersInfo(), which gives an IP_ADAPTER_INFO output, take the AdapterName string. This should be a GUID for the adapter. For (ipv4 at least), under HKLM\SYSTEM\CurrentControlSet\Control\Network{4D36E972-E325-11CE-BFC1-08002BE10318}\{INSERT GUID HERE}\Connection, the value Name should contain the "friendly" network name.




回答2:


I'll have to double check, but I think this might be in the registry somewhere... I'll get back to this.

hklm/system/currentcontrolset/control/network

might help.

I did not find exactly what i thought I would though, sorry

EDIT This might help too:

http://www.java2s.com/Tutorial/CSharp/0520__Windows/Getthenetworkdevicenamedeviceservicename.htm

specifically: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\

I do not know if this is guaranteed for future, or not "approved" method, but it seems to have the info you need.




回答3:


Your best bet is to use the Win32 API calls known collectively as "IP Helper". That will get you just about all the same information that you could get with a call to "ipconfig" from the CLI.

In particular, I'd start by looking at the "GetAdaptersInfo" function.

And, of course, since this part of the Win32 API, you can use pure C/C++ without needing to parse output from an outside utility.



来源:https://stackoverflow.com/questions/380990/network-interface-settings-in-embedded-windows-xp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!