Bonjour à tous : )
Suivent deux codes. Apparemment identiques. Mais, à l'exécution du second, j'ai ce message systématique (d'autres si je cache l'application, etc):
Le code fonctionnant :
Celui qui plante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
34
35
36
37
38
39
40
41
42
43
44
45 Procedure Appel_6; Var StartInfo : TStartupInfo; ProcessInfo : TProcessInformation; Fin : Boolean; Ligne_Cmd : string; begin FillChar(StartInfo,SizeOf(StartInfo),#0); StartInfo.cb := SizeOf(StartInfo); StartInfo.wShowWindow := SW_SHOWMAXIMIZED; StartInfo.dwFlags := STARTF_USESHOWWINDOW; Form1.Visible := False; Ligne_Cmd := PCHar(Nom_Editeur) + ' ' + PChar(F_Cible); If CreateProcess(Nil, PChar(Ligne_Cmd) , Nil, Nil, False, 0, Nil, Nil, StartInfo, ProcessInfo) then Begin Fin := False; Repeat Case WaitForSingleObject(ProcessInfo.hProcess, 200)Of WAIT_OBJECT_0 : Fin := True; { L'application est terminée, on sort } WAIT_TIMEOUT : ; { elle n'est pas terminée, on continue d'attendre } End; Application.ProcessMessages; Until Fin; End Else begin RaiseLastOSError; Form1.Visible := True; end; Form1.Visible := True; SetForegroundWindow(Handle_App); End;
Pourquoi plante-t-il seulement sur le second ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
34
35
36
37
38
39
40
41
42
43
44 Procedure Appel_Editeur(Nom_Editeur : string; F_Cible : string); Var StartInfo : TStartupInfo; ProcessInfo : TProcessInformation; Fin : Boolean; Ligne_Cmd : string; Num_Err : integer; begin FillChar(StartInfo,SizeOf(StartInfo),#0); StartInfo.cb := SizeOf(StartInfo); Startinfo.dwFlags := STARTF_USESHOWWINDOW; StartInfo.wShowWindow := SW_SHOWMAXIMIZED; Form1.Visible := False; { Lancement de la ligne de commande } Ligne_Cmd := PCHar(Nom_Editeur) + ' ' + PChar(F_Cible); If CreateProcess(Nil, PChar(Ligne_Cmd) , Nil, Nil, False, 0, Nil, Nil, StartInfo, ProcessInfo) then Begin Fin := False; Repeat Case WaitForSingleObject(ProcessInfo.hProcess, 200)Of WAIT_OBJECT_0 : Fin := True; { L'application est terminée, on sort } WAIT_TIMEOUT : ; { elle n'est pas terminée, on continue d'attendre } End; Application.ProcessMessages; Until Fin; End Else begin Form1.Visible := True; RaiseLastOSError; Num_Err := GetLastError; MessageDlg('ERREUR NUMERO : ' + IntToStr(Num_Err), mtError, [mbOK], 0); end; Form1.Visible := True; SetForegroundWindow(Handle_App); end;
Merci :hello:
Partager