Arret d'une application

danfranjo Messages postés 33 Date d'inscription dimanche 3 avril 2005 Statut Membre Dernière intervention 14 février 2009 - 27 août 2005 à 20:57
cs_ticok Messages postés 5 Date d'inscription lundi 26 mai 2003 Statut Membre Dernière intervention 30 août 2005 - 30 août 2005 à 08:12
Bonsoir,

Quelqu'un sait-il comment on peut detecter l'arret d'une application en Delphi
Merci d'avance

3 réponses

cs_grandvizir Messages postés 1106 Date d'inscription samedi 8 novembre 2003 Statut Membre Dernière intervention 3 septembre 2006 22
28 août 2005 à 10:45
Tout dépend de la manière dont tu fermes ton appli :
1) TerminateProcess est radical, l'appli ne détectera rien
2) WM_EndSession ou WM_Close peuvent être interceptés (surtout le 2ème)
3) Si tu fais Application.Terminate, alors t'appelles une procédure juste avant et qui fera les dernières opérations.

Intercepter des messages.

===========
Validez les réponses si ok...

ViewVite XP : HTML
0
danfranjo Messages postés 33 Date d'inscription dimanche 3 avril 2005 Statut Membre Dernière intervention 14 février 2009
28 août 2005 à 10:55
Merci de ta réponse
En réalité, je suis dans une appli Delphi qui lance une autre appli par ShellExecute
Je voudrais savoir comment je peux detecter la fin de cette 2éme appli
Il me semble avoir vu du code sur ce sujet, mais je ne le retrouve pas
0
cs_ticok Messages postés 5 Date d'inscription lundi 26 mai 2003 Statut Membre Dernière intervention 30 août 2005
30 août 2005 à 08:12
Salut,

Voila une focntion qui devrait faire ca:



function LaunchAndWait(sFile: String; sparam: String; wShowWin: Word): Boolean;

var

cExe: array [0..255] of Char;

sExe: string;

pcFile: PChar;

StartInfo: TStartupInfo;

ProcessInfo: TProcessInformation;

begin

Application.ProcessMessages ;

Result:=True;

FindExecutable(PChar(ExtractFileName(sFile)), PChar(ExtractFilePath(sFile)), cExe);

sExe:= string(cExe);

pcFile:=PChar(sparam);

Edit1.Text:=sExe +pcFile;

ZeroMemory(@StartInfo, SizeOf(StartInfo));

with StartInfo do begin

cb:=SizeOf(StartInfo);

dwFlags:=STARTF_USESHOWWINDOW;

wShowWindow:=wShowWin;

end;

Application.ProcessMessages ;

if CreateProcess(PChar(sExe), pcFile, nil, nil, True, 0, nil, nil, StartInfo, ProcessInfo)

then WaitForSingleObject(ProcessInfo.hProcess, INFINITE)

else Result:=False;

Application.ProcessMessages ;

end;



Et puis tu appels la fonction comme ceci:




if not LaunchAndWait('cxtotiff.exe', param, SW_HIDE) then

begin

//ici ton code

end;





Fab
0
Rejoignez-nous