Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
function Run(EXEName : string; Arguments : TStrings; HideEXE : Boolean) : THandle;
var
RunInfo : TProcessInformation;
StartupInfo : TStartupInfo;
ACommandLine : string;
Counter : Integer;
begin
Result := 0;
Screen.Cursor := crHourglass;
try
ACommandLine := '"' + EXEName + '"';
if Arguments <> nil then
begin
for Counter := 0 to Arguments.Count - 1 do
ACommandLine := ACommandLine + ' "' + Arguments[Counter] + '"';
end;
with StartupInfo do
begin
cb := SizeOf(StartupInfo);
lpReserved := nil;
dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
if HideEXE then
wShowWindow := SW_HIDE
else
wShowWindow := SW_SHOW;
lpDesktop := nil;
lpTitle := nil;
cbReserved2 := 0;
lpreserved2 := nil;
end;
if Windows.CreateProcess(nil, // Application name
PChar(ACommandLine), // Command line
nil, // Process security attributes
nil, // Thread security attributes
False, // Do not inherited file handles
CREATE_NEW_CONSOLE, // Creation flags (default priority)
nil, // Share environment settings
nil, // Startup directory
StartupInfo, // No Startup window structure
RunInfo) then // Output information
begin
Result := RunInfo.hProcess;
Windows.CloseHandle(RunInfo.hThread); // we don't return it; no one can use it
Application.ProcessMessages;
end
else
raise Exception.Create('Error creating process ' + EXEName + '. Error code is ' + IntToStr(GetLastError));
finally
Screen.Cursor := crDefault;
end;
end;
function GetRunExitCode(EXEName : string; TimeOutSeconds : Integer; Arguments : TStrings; HideEXE : Boolean) : DWord;
var
ProcessHandle : THandle;
ExpireTime : TDateTime;
begin
ProcessHandle := Run(EXEName, Arguments, HideEXE);
if ProcessHandle > 32 then
try
Result := STILL_ACTIVE;
ExpireTime := Now + (TimeoutSeconds / (24 * 60 * 60));
while (Result = STILL_ACTIVE) do
begin
Sleep(500);
if (ExpireTime < Now) then
raise Exception.Create('Timed-out waiting for ' + EXEName + ' to finish');
Windows.GetExitCodeProcess(ProcessHandle, Result);
end;
finally
Windows.CloseHandle(ProcessHandle);
end;
end;