What happens when a call to the following does not detect an internet connection?
I have the following in an AfterShow event of my main form
procedure TfrmMain.WmAfterShow(var Msg: TMessage);
begin
Application.ProcessMessages;
if WebUpdate.NewVersionAvailable then
begin
stsVersionStatus.Blinking := True;
stsVersionStatus.Caption := 'New Version Available'
end
else
begin
stsVersionStatus.Blinking := False;
stsVersionStatus.Caption := 'Version is Current';
end;
end;
I would like to also show when a user is not connected to the internet. Is this possible?
Something like:
begin
stsVersionStatus.Blinking := False;
stsVersionStatus.Caption := 'No Internet Connection';
end
I suppose I'm not doing this correctly. I dropped a TWebConnect component on my form, did not set any properties (leaving them all set to thier default settings) and executed my code and it appeared to work as expected. I then disconnected my LAN wire effectively disconnecting from the internet and tried it again and WebConnect.Connected still returns true. So what am I missing? I tired F1 help (does not have help available) and then tried to look in the document folder but could not seem to find where it is located in of of the PDF files. Any tips appreciated.
procedure TfrmMain.WmAfterShow(var Msg: TMessage);
begin
Application.ProcessMessages;
if not WebConnect.Connected then
begin
stsVersionStatus.Blinking := False;
stsVersionStatus.Caption := 'No Internet';
end
else if WebUpdate.NewVersionAvailable then
begin
stsVersionStatus.Blinking := True;
stsVersionStatus.Caption := 'Update Available';
sndPlaySound('C:\Windows\Media\Alarm01.wav', SND_ASYNC {SND_NODEFAULT Or SND_ASYNC Or SND_LOOP});
end
else
begin
stsVersionStatus.Blinking := False;
stsVersionStatus.Caption := 'Current';
end;
end;
Not sure if the Windows API used in TWebConnect is still reliable in the newest Windows versions.
For more generic solutions to check for an internet connection, see