var
dw: DWORD;
begin
hEvent := CreateEvent(nil, TRUE, FALSE, 'RasNotification');
if hEvent = 0 then
ShowMessage('Error in CreateEvent')
else begin
dw := RasConnectionNotification(INVALID_HANDLE_VALUE,
hEvent, RASCN_Disconnection+RASCN_Connection);
if dw <> 0 then
ShowMessage('Error in RasConnectionNotification')
else begin
while true do
begin
if WaitForSingleObject(hEvent, INFINITE) = WAIT_OBJECT_0 then
begin
ShowMessage('检测到网络连接变化');
//***********************************************
//用RasGetConnectStatus得到具体是什么变化
//***********************************************
ResetEvent(hEvent);
end;
end;
end;
end;
Result := 0;
end;