Einzelnen Beitrag anzeigen

mumu

Registriert seit: 28. Okt 2003
Ort: Bamberg
519 Beiträge
 
#1

Internet-Verbindung als Event abfangen und anzeigen

  Alt 30. Jan 2004, 17:43
Frage: ich versuche das online und offline gehen mit einem event signalisieren, was mach ich hier falsch???

Delphi-Quellcode:
const
  RASCN_Connection = $00000001;
  RASCN_Disconnection = $00000002;
  RASCN_BandwidthAdded = $00000004;
  RASCN_BandwidthRemoved = $00000008;

function RasConnectionNotification(hrasconn: THRasConn; hEvent: THandle; dwFlags: Longint): longint; external 'rasapi32.dllname 'RasConnectionNotificationA';


var pCanRead: PWOHandleArray;
begin
  pCanRead:=AllocMem(2*sizeof(THandle));
  pCanRead[0]:=CreateEvent(nil,True,False,'RASStatusNotificationObject1');
  RasConnectionNotification(INVALID_HANDLE_VALUE, pCanRead[0], RASCN_Connection);
  if pCanRead[0] = 0 then showmessage('geht net');
  pCanRead[1]:=CreateEvent(nil,True,False,'RASStatusNotificationObject2');
  if pCanRead[1] = 0 then showmessage('geht net');
  RasConnectionNotification(INVALID_HANDLE_VALUE, pCanRead[1], RASCN_Connection);
  if WaitForMultipleObjects(2, @pCanRead[0],   False, 20) = WAIT_OBJECT_0 then showmessage('online');
  if WaitForMultipleObjects(2, @pCanRead[1],   False, 20) = WAIT_OBJECT_0+1 then showmessage('offline');
end;
danke schonmal im vorraus
  Mit Zitat antworten Zitat