Fórum Verificar se aplicação está sendo executada. #367573
07/01/2009
0
Obrigado
Edusjc
Curtir tópico
+ 0Posts
07/01/2009
Edjlle
var hHandle: THandle; sExename: string; begin // Supondo que o nome do main form seja Form1 hHandle := FindWindow(´TForm1´, nil); if hHandle = 0 then begin // Teste.exe é o nome do executável sExename := ExtractFilePath(Application.ExeName)+´Teste.exe´; end else begin // Executa o programa - se estiver no drive C if ShellExecute(Handle, PChar(´open´), PChar(sExename), 0, PChar(´C:\´), SW_SHOWMINNOACTIVE) <= 32 then ShowMessage(´Executável não encontrado´);
Gostei + 0
07/01/2009
Edjlle
o código certo é:
var hHandle: THandle; sExename: string; begin // Supondo que o nome da classe do main form seja TForm1 hHandle := FindWindow(´TForm1´, nil); if hHandle <> 0 then begin ShowMessage(´Executável já rodando.´); end else begin // Executa o programa (chamado Teste.exe) - do diretório desta aplicação sExename := ExtractFilePath(Application.ExeName)+´Teste.exe´; if ShellExecute(self.Handle, PChar(´open´), PChar(sExename), 0, PChar(´C:\´), SW_NORMAL) <= 32 then ShowMessage(´Executável não encontrado´); end; end;
Gostei + 0
07/01/2009
Edusjc
Obrigado
Gostei + 0
07/01/2009
Edjlle
http://www.activedelphi.com.br/modules.php?op=modload&name=Downloads&file=index&req=viewdownloaddetails&lid=527&ttitle=Finaliza_Processos
Você precisará estar logado para baixar.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)