这个是自己写的demo,ip变化后执行了回调函数,然后就异常了
#include "stdafx.h"
#include <WinSock2.h>
#pragma comment(lib,"Ws2_32.lib")
#include <netioapi.h>
#include <iphlpapi.h>
#include <stdio.h>
#pragma comment(lib,"Iphlpapi.lib")
VOID
InterfaceCbk (
IN PVOID CallerContext,
IN PMIB_IPINTERFACE_ROW Row OPTIONAL,
IN MIB_NOTIFICATION_TYPE NotificationType
)
{
printf("aaa \n");
}
int _tmain(int argc, _TCHAR* argv[])
{
DWORD ret;
HANDLE hand = NULL;
ret = NotifyIpInterfaceChange(AF_UNSPEC, InterfaceCbk, NULL, FALSE, &hand);
int i = 0;
while (true)
{
Sleep(1000);
}
return 0;
}