//=============Internetseite aufrufen===========================================
procedure TForm2.Label2Click(Sender: TObject);
const
INTERNET_CONNECTION_MODEM = 1;
INTERNET_CONNECTION_LAN = 2;
INTERNET_CONNECTION_PROXY = 4;
INTERNET_CONNECTION_MODEM_BUSY = 8;
var
dwConnectionTypes: DWORD;
begin
dwConnectionTypes :=
INTERNET_CONNECTION_MODEM +
INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
if IsConnectedToInternet(@dwConnectionTypes)
then
ShellExecute(
Handle,'
Open',PChar(TLabel(Sender).Caption),
nil,
nil,SW_SHOW)
else
MessageDlgPos('
Es besteht keine Verbindung zum Internet',mtInformation,[mbOk],0,320,180);
end;
function TForm2.IsConnectedToInternet(lpdwFlags: LPDWORD): Boolean;
const
WininetDLL = '
wininet.dll';
var
hWininetDLL: THandle;
dwReserved: DWORD;
fn_InternetGetConnectedState:
function(lpdwFlags: LPDWORD; dwReserved: DWORD): BOOL;
stdcall;
begin
Result := False;
dwReserved := 0;
hWininetDLL := LoadLibrary(WininetDLL);
if hWininetDLL > 0
then
begin
@fn_InternetGetConnectedState := GetProcAddress(hWininetDLL,'
InternetGetConnectedState');
if Assigned(fn_InternetGetConnectedState)
then
begin
Result := fn_InternetGetConnectedState(lpdwFlags, dwReserved);
end;
FreeLibrary(hWininetDLL);
end
else
raise Exception.Create('
Unable to locate function InternetGetConnectedState in library ' + WininetDLL);
end;