error2019:IcmpCreateFile和IcmpSendEcho
1>源.obj : error LNK2019: 无法解析的外部符号 _IcmpCreateFile@0,该符号在函数 "unsigned long __cdecl ThreadProc_ICMP(void *)" (?ThreadProc_ICMP@@YAKPAX@Z) 中被引用1>源.obj : error LNK2019: 无法解析的外部符号 _IcmpSendEcho@32,该符号在函数 "unsigned long __cdecl ThreadProc_ICMP(void *)" (?ThreadProc_ICMP@@YAKPAX@Z) 中被引用
1>D:\code\empty_Test\Debug\empty_Test.exe : fatal error LNK1120: 2 个无法解析的外部命令
代码:
程序代码:
DWORD ThreadProc_ICMP(LPVOID lpParam)//ICMP { HANDLE hIcmpFile; unsigned long ipaddr = INADDR_NONE; DWORD dwRetVal = 0; char SendData[20] = "123456789abcdef";// LPVOID ReplyBuffer = NULL; DWORD ReplySize = 0; ipaddr=inet_addr(ip);// if (ipaddr == INADDR_NONE) { Printf_Debug("inet_addr",WSAGetLastError()); exit(0); } hIcmpFile = IcmpCreateFile(); if (hIcmpFile == INVALID_HANDLE_VALUE) { Printf_Debug("IcmpCreateFile",WSAGetLastError()); exit(0); } ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData); ReplyBuffer = (VOID*) malloc(ReplySize); if (ReplyBuffer == NULL) { Printf_Debug("malloc",WSAGetLastError()); exit(0); } while(1)//每分钟发一次ping包 { dwRetVal = IcmpSendEcho(hIcmpFile, ipaddr, SendData, sizeof(SendData), NULL, ReplyBuffer, ReplySize, 1000); Sleep(60000); } }
代码参考自:https://msdn.(v=vs.85).aspx