Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Check if computer is connected to the Internet

Title: Check if computer is connected to the Internet Question: Are we Connected to the Internet? Answer: function FuncAvail(VLibraryname, VFunctionname: string; var VPointer: pointer): boolean; // // this function check if VFunctionname exists in VLibraryname // var Vlib: tHandle; begin Result := false; if LoadLibrary(PChar(VLibraryname)) = 0 then exit; Vlib := GetModuleHandle(PChar(VLibraryname)); if Vlib 0 then begin VPointer := GetProcAddress(Vlib, PChar(VFunctionname)); if VPointer NIL then Result := true; end; end; Code Button1 on a Form1: procedure TForm1.Button1Click(Sender: TObject); // // Call shell32.dll for highter Win98 // else call url.dll // var InetIsOffline : function(dwFlags: DWORD):BOOL; stdcall; begin if FuncAvail('url.dll', 'InetIsOffline', @InetIsOffline) then if InetIsOffLine(0) then ShowMessage('Not connected') else ShowMessage('Connected!'); end;