-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExecutaApp.pas
More file actions
33 lines (33 loc) · 937 Bytes
/
ExecutaApp.pas
File metadata and controls
33 lines (33 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
procedure ExecutaApp(Nome,State,NomeExec,Path:Pchar;Estado:Integer);
//
// Executa um aplicativo somente se ele não estiver aberto, caso
// contrário apenas chama-o
//
// Valores para Estdo: SW_SHOWNORMAL Janela em modo normal
// SW_MAXIMIZE Janela maximizada
// SW_MINIMIZE Janela minimizada
// SW_HIDE Janela Escondida
//
// Veja um exemplo de como chamar a calculadora do Windows
//
// ExecutaApp('CALCULADORA','OPEN','CALC.EXE','C:\WINDOWS',8);
//
// Onde 'CALCULADORA' é o nome da janela do aplicativo
//
var
TheWindows: HWND;
begin
theWindows := FindWindow(NIL,Nome);
if TheWindows <> 0 then
begin
SetForegroundWindow(TheWindows)
end
else
begin
if (Estado > 3) or (Estado < 1) then
begin
Estado := 1;
end;
ShellExecute(Application.Handle,State,NomeExec,NIL,Path,Estado);
end;
end;