LAN Web TCP Delphi

Title: Force Internet Explorer "Work Online" without reboot
Question: I have noticed that occasionally a user puts Internet Explorer into "Work Offline" mode. This is a nuisance when using unattended TWebBrowser as your component is also OFFLINE.
There is a flag (GlobalUserOffline) in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
Setting this flag to 0 resets to ONLINE, but IE and TWebbrowser will NOT acknowledge the change until they are restarted. The following function will RESET and FORCE both IE and TWebbrowser to respond to the changes immediately. Uses functionality supplied by delphi unit WinINet.
Answer:
uses Windows, Registry, WinINet;
const
C_REGKEY = 'Software\Microsoft\Windows\CurrentVersion\Internet Settings';
C_REGVAL = 'GlobalUserOffline';
procedure ForceOnLine;
var oReg : TRegistry;
hInet : HInterNet;
begin
// Check if mode is "Work Offline"
oReg := TRegistry.Create;
oReg.RootKey := HKEY_CURRENT_USER;
oReg.LazyWrite := false;
if oReg.OpenKey(C_REGKEY,false) then begin
if oReg.ValueExists(C_REGVAL) then begin
if oReg.ReadInteger(C_REGVAL) 0 then begin
// Reset toe "Work Online"
oReg.WriteInteger(C_REGVAL,0);
end;
end;
oReg.CloseKey;
// Force IE to Re-Read Registry Settings
hInet := InterNetOpen(PChar(ParamStr(0)),INTERNET_OPEN_TYPE_DIRECT,
nil,nil,INTERNET_FLAG_OFFLINE);
try
if hInet nil then
InterNetSetOption(hInet,INTERNET_OPTION_SETTINGS_CHANGED,nil,0);
finally
InterNetCloseHandle(hInet);
end;
end;
oReg.Free;
end;