winxp系统.如下: char m_AdapterList[Max_Num_Adapter][1024]; //存放网卡名称 for(DWORD dw=0; dw<Max_Num_Adapter; dw++)
{
ZeroMemory(m_AdapterList[dw],sizeof(m_AdapterList[dw]));
}
DWORD m_dwAdaptCount=0;
char AdapterName[8192];
//WCHAR AdapterName[8192];
ULONG AdapterLength = sizeof(AdapterName);
ZeroMemory(AdapterName,sizeof(AdapterName));
AfxMessageBox("Get net card name");
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE)
{
AfxMessageBox("取网卡名称错误\n");
return FALSE;
} //AfxMessageBox(AdapterName);
//AfxMessageBox(AdapterName);
char *temp,*temp1;
temp=AdapterName;
temp1=AdapterName; DWORD i=0;
AfxMessageBox("open the net card");
//AfxMessageBox(AdapterName); while ((*temp!='\0')||(*(temp-1)!='\0'))
{
if (*temp=='\0')
{
memcpy(m_AdapterList[i],temp1,temp-temp1);
temp1=temp+1;
i++;
}
temp++;
}
AfxMessageBox("open the net card");
m_dwAdaptCount = i;
for (i=0;i<m_dwAdaptCount;i++)
TRACE("\n%d- %s\n",i+1,m_AdapterList[i]);
TRACE("\n");
AfxMessageBox("open the net card");
{
ZeroMemory(m_AdapterList[dw],sizeof(m_AdapterList[dw]));
}
DWORD m_dwAdaptCount=0;
char AdapterName[8192];
//WCHAR AdapterName[8192];
ULONG AdapterLength = sizeof(AdapterName);
ZeroMemory(AdapterName,sizeof(AdapterName));
AfxMessageBox("Get net card name");
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE)
{
AfxMessageBox("取网卡名称错误\n");
return FALSE;
} //AfxMessageBox(AdapterName);
//AfxMessageBox(AdapterName);
char *temp,*temp1;
temp=AdapterName;
temp1=AdapterName; DWORD i=0;
AfxMessageBox("open the net card");
//AfxMessageBox(AdapterName); while ((*temp!='\0')||(*(temp-1)!='\0'))
{
if (*temp=='\0')
{
memcpy(m_AdapterList[i],temp1,temp-temp1);
temp1=temp+1;
i++;
}
temp++;
}
AfxMessageBox("open the net card");
m_dwAdaptCount = i;
for (i=0;i<m_dwAdaptCount;i++)
TRACE("\n%d- %s\n",i+1,m_AdapterList[i]);
TRACE("\n");
AfxMessageBox("open the net card");
解决方案 »
- 有什么办法让"..遇到问题需关闭..发送错误报告"这个框不跳出来
- 关于当前桌面的广播
- XP下正常,VISTA下程序退出出现(NTDLL.DLL): 0xC0000005: Access Violation的问题
- 求vc2005环境的数据库编程demo!
- 急问求救:include 一个库头文件,编译后此文件报错,原因为何?
- 包含了类的头文件,却仍然提示类没有定义错误/
- 数据采集多线程的数据传递问题,谢谢大家。
- 请脚vc的多线程问题
- 怎么让我的VC变成中文版的?更奇怪的是VC安装后,原来中文版的网络蚂蚁也成英文版的了。
- 程序出错原因?VC6,Release, static Link, 无提示退出
- 求教:工具条按钮的多行排列
- 数组超限的异常怎么处理?
PULONG BufferSize
)
Retrieve the list of available network adapters and their description.
Parameters:
pStr User allocated string that will be filled with the names of the adapters.
BufferSize Length of the buffer pointed by pStr. If the function fails, this variable contains the number of bytes that are needed to contain the adapter list. Returns:
If the function succeeds, the return value is nonzero. If the return value is zero, BufferSize contains the number of bytes that are needed to contain the adapter list.
Usually, this is the first function that should be used to communicate with the driver. It returns the names of the adapters installed on the system and supported by WinPcap. After the names of the adapters, pStr contains a string that describes each of them.
After a call to PacketGetAdapterNames pStr contains, in succession:a variable number of ASCII strings, each with the names of an adapter, separated by a "\0"
a double "\0"
a number of ASCII strings, each with the description of an adapter, separated by a "\0". The number of descriptions is the same of the one of names. The fisrt description corresponds to the first name, and so on.
a double "\0".
Definition at line 2028 of file Packet32.c.
#include <windows.h>
#include <stdio.h>int main()
{
char AdapterName[8192];
ULONG AdapterLength = sizeof(AdapterName); ZeroMemory(AdapterName,sizeof(AdapterName));
printf("Get net card name:\n");
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE)
{
printf("取网卡名称错误\n");
return -1;
}
printf("%s\n",AdapterName);
return 0;
}
-------------------
结果:
Get net card name:
\Device\NPF_GenericNdisWanAdapter