阅读:819回复:0
请教:用winpcap驱动的packet.dll时---------
请教:我在Win2000下基于winpcap驱动的packet.dll开发程序时,这条语句 lpAdapter = PacketOpenAdapter(AdapterList[0]); 怎么总是执行时出错呀,编译没问题,错误信息是~~~~指令引用的内存不能读,可是相同的程序段在Dos窗口的Win32程序中可以运行的好好的,谁有类似的经验吗,请给我指点!!!
部分源代码:(我是新手,基本上是别的程序上的) char AdapterList[2][1024]; LPADAPTER lpAdapter =NULL; LPPACKET lpPacket=NULL; int i=0; DWORD dwErrorCode; DWORD dwVersion; DWORD dwWindowsMajorVersion; //unicode strings (winnt) WCHAR AdapterName[8192]; WCHAR *temp,*temp1; ULONG AdapterLength; char buffer[256000]; struct bpf_stat stat; //初始化网卡Adapters installed dwVersion=GetVersion(); dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); if (!(dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4)) { // 则为Windows NT或者win2000系统 AdapterLength = sizeof(AdapterName); if(PacketGetAdapterNames((char*)AdapterName,&AdapterLength)==FALSE){ MessageBox(\"Unable to retrieve the list of the adapters!\"); return -1; } temp=AdapterName; temp1=AdapterName; while ((*temp!=\'\\0\')||(*(temp-1)!=\'\\0\')) { if (*temp==\'\\0\') { memcpy(AdapterList,temp1,(temp-temp1)*2); temp1=temp+1; i++; } temp++; } } else{ MessageBox(\"对不起,您的操作系统不是winnt或win2000\"); return 0; } lpAdapter = PacketOpenAdapter(AdapterList[0]); |
|
|