简体   繁体   English

嵌入式Windows XP中的网络接口设置

[英]Network interface settings in embedded Windows XP

How can we get the network interface name (ie the one that appears in the "Network connections" dialog) given the device description (ie 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 (eg netsh, ipconfig...), or a combination of both. 我们必须使用纯C / C ++语言,或通过一些标准命令行工具(例如netsh,ipconfig ...)或两者的组合来实现。

We CAN'T use the .NET API, because of deployment problems (the application must run on an XP embedded without .NET Framework). 由于部署问题,我们无法使用.NET API(应用程序必须在没有.NET Framework的情况下在嵌入式XP上运行)。

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. SDK API GetIfTable和GetIfEntry似乎很有希望,但在我们的系统上,所有MIB_IFROW字段都被正确填充,除了“wszName”字段,它仍然未初始化。

I was able to do this via the registry. 我能够通过注册表完成此操作。 Using GetAdaptersInfo(), which gives an IP_ADAPTER_INFO output, take the AdapterName string. 使用提供IP_ADAPTER_INFO输出的GetAdaptersInfo()获取AdapterName字符串。 This should be a GUID for the adapter. 这应该是适配器的GUID。 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. 对于(至少ipv4),在HKLM \\ SYSTEM \\ CurrentControlSet \\ Control \\ Network {4D36E972-E325-11CE-BFC1-08002BE10318} \\ { INSERT GUID HERE } \\ Connection下,值Name应包含“友好”网络名称。

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 HKLM /系统/ CurrentControlSet /控制/网络

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 http://www.java2s.com/Tutorial/CSharp/0520__Windows/Getthenetworkdevicenamedeviceservicename.htm

specifically: HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\ 具体来说: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. 我不知道这是否可以保证未来,或者不是“已批准”的方法,但它似乎有你需要的信息。

Your best bet is to use the Win32 API calls known collectively as " IP Helper ". 最好的办法是使用统称为“ IP Helper ”的Win32 API调用。 That will get you just about all the same information that you could get with a call to "ipconfig" from the CLI. 这将为您提供从CLI调用“ipconfig”时可以获得的所有相同信息。

In particular, I'd start by looking at the " GetAdaptersInfo " function. 特别是,我首先看一下“ GetAdaptersInfo ”函数。

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. 当然,从Win32 API的这一部分开始,您可以使用纯C / C ++而无需解析外部实用程序的输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM