积极答复者
获取网卡名

问题
-
使用 SetupDiGetDeviceRegistryProperty(hDevInfo,&DeviceInfoData,SPDRP_DEVICEDESC ,&DataT,(PBYTE)buffer_name,buffer_name_size,&buffer_name_size); //SPDRP_DEVICEDESC
碰到通型号的在系统里会在第二块卡名后加上 ".#2" 来区分。但上面函数取得的名字都是一样的。使用:SetupDiGetDeviceRegistryProperty(hDevInfo,&DeviceInfoData,SPDRP_FRIENDLYNAME ,&DataT,(PBYTE)buffer_name,buffer_name_size,&buffer_name_size);则取不到数据 //SPDRP_FRIENDLYNAME
请高手指导下应该怎么取。。
答案
-
GetAdaptersAddresses 这个API函数可以得到网卡的名称。
您上面提到的SetupDiGetDeviceRegistryProperty是DDK中的函数吧。
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
- 已建议为答案 Helen Zhao 2012年6月12日 7:02
- 已标记为答案 Helen Zhao 2012年6月15日 2:51
全部回复
-
GetAdaptersAddresses 这个API函数可以得到网卡的名称。
您上面提到的SetupDiGetDeviceRegistryProperty是DDK中的函数吧。
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
- 已建议为答案 Helen Zhao 2012年6月12日 7:02
- 已标记为答案 Helen Zhao 2012年6月15日 2:51
-
你好! 谢谢你!这个是可以。但我还有个疑问。。
我本意是想通过网卡名来禁用或启用网卡。 在用SetupDiGetDeviceRegistryProperty时,当网卡型号一样并有多块网卡时就发现用 SPDRP_DEVICEDESC 取得 的数据是一样的(而windows系统设备管理中看到会在第二块卡的名称后加上 #2 来区分)。禁用启用时用刚取得的名为依据的话就不好判定到底禁用的是哪个网卡(SetupDiCallClassInstaller)
如果用 GetAdaptersAddresses 取得网卡名,又怎么知道 它的HDEVINFO,PSP_DEVINFO_DATA 感觉这里面的关系还没理清。
或有其他根据网卡名来禁用 启用的请告诉下,我想通过网卡名是想比较直观点来知道是使用哪块卡。
- 已编辑 pdjqq 2012年6月7日 23:11