Created
November 4, 2020 10:55
-
-
Save ssrlive/0a86f78f3fd2f02461358bb273f7fb80 to your computer and use it in GitHub Desktop.
monitor windows network status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <winsock2.h> | |
#include <iphlpapi.h> | |
#include <stdio.h> | |
#include <windows.h> | |
#pragma comment(lib, "iphlpapi.lib") | |
#pragma comment(lib, "ws2_32.lib") | |
void main() | |
{ | |
OVERLAPPED overlap; | |
DWORD ret; | |
HANDLE hand = NULL; | |
overlap.hEvent = WSACreateEvent(); | |
ret = NotifyAddrChange(&hand, &overlap); | |
if (ret != NO_ERROR) | |
{ | |
if (WSAGetLastError() != WSA_IO_PENDING) | |
{ | |
printf("NotifyAddrChange error...%d\n", WSAGetLastError()); | |
return; | |
} | |
} | |
if ( WaitForSingleObject(overlap.hEvent, INFINITE) == WAIT_OBJECT_0 ) | |
printf("IP Address table changed..\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment