1. Application Is Responding

  2. App Exec

  3. App Restart

  4. Exec And Wait

  5. App Maximize

  6. App Minimize


Home

 

Pages: 1  |  2  |  3  |  4  |  5  |


Application Is Responding

 

function AppIsResponding(const ClassName: string; const TimeOut: Cardinal): Boolean;
var
Res: DWORD;
h: HWND;
bClassFound,
bSendMessage: Boolean;
begin
 

bSendMessage := FALSE;
h := FindWindow(PChar(ClassName), nil);
bClassFound := (h <> 0);
if bClassFound then
bSendMessage := (SendMessageTimeout(H,
WM_NULL,
0,
0,
SMTO_NORMAL or SMTO_ABORTIFHUNG,
TIMEOUT,
Res) <> 0);
result := (bClassFound and bSendMessage);
 

end;

 

 

Back to Top

App Exec

 

function AppExec(const CmdLine, CmdParams: string; const CmdShow: Integer): Boolean;
begin
 
result := (ShellExecute(GetCurrentProcess,
'open',
PChar(CmdLine),
PChar(CmdParams),
'',
CmdShow) > 32);
 
end;

 

Back to Top

App Restart

procedure AppRestart;
begin
 

AppExec(ParamStr(0), '', SW_SHOW);  // <<-- Function AppExec is here
TerminateProcess(GetCurrentProcess, 0);
 

end;

 

Back to Top

 


Exec And Wait

uses ShellAPI;

procedure ExecAndWait(const FileName, Params: string; const CmdShow: Integer);
var
exInfo: TShellExecuteInfo;
Ph: DWORD;
begin
 

        FillChar(exInfo, SizeOf(exInfo), 0);
        with exInfo do
        begin
            cbSize := SizeOf(exInfo);
            fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
            Wnd := GetActiveWindow();
            ExInfo.lpVerb := 'open';
            ExInfo.lpParameters := PChar(Params);
            lpFile := PChar(FileName);
            nShow := CmdShow;
end;
if ShellExecuteEx(@exInfo) then
    Ph := exInfo.HProcess
else
begin
    ShowMessage(SysErrorMessage(GetLastError));
    Exit;
end;
while WaitForSingleObject(ExInfo.hProcess, 50) <> WAIT_OBJECT_0 do
    ProcessMessages;
CloseHandle(Ph);

end
;

 

Back to Top

 


App Maximize

procedure AppMaximize(hWin: HWND);
begin
 

SendMessage(hWin, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
 

end;
 

Back to Top

App Minimize

procedure AppMinimize(hWin: HWND);
begin
 

SendMessage(hWin, WM_SYSCOMMAND, SC_MINIMIZE, 0);
 

end;

 
Back to Top

Copyright 2006  [PatilanSoft]. All rights reserved.