Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
prog:lazarus:classes:tprocess [06/03/2021 15:34]
thierry [TProcessOptions]
prog:lazarus:classes:tprocess [24/04/2021 13:05] (Version actuelle)
thierry [Sources et Ressources]
Ligne 102: Ligne 102:
 end. end.
 </​code>​ </​code>​
 +==== Procédure interessantes ====
 +=== Terminate ===
 +<code delphi>
 +Function Terminate (AExitCode : Integer): Boolean; virtual;
 +    ...
 +Function TProcessnamemacro.Terminate(AExitCode : Integer) : Boolean;
 +begin
 +  Result:​=False;​
 +  If ExitStatus=Still_active then
 +    Result:​=TerminateProcess(Handle,​AexitCode);​
 +end;
 +</​code>​
 +Appel au final la fonction ''​TerminateProcess''​ de Windows
 +<code delphi>
 +function TerminateProcess(hProcess:​HANDLE;​ uExitCode:​UINT):​WINBOOL;​ external '​kernel32'​ name '​TerminateProcess';​
 +</​code>​
 +D'​aprés la [[https://​docs.microsoft.com/​en-us/​windows/​win32/​api/​processthreadsapi/​nf-processthreadsapi-terminateprocess|Doc de TerminateProcess dans Windows]] le paramètre ''​AExitCode''​ est le code de sortie à utiliser par le processus et les threads terminés à la suite de cet appel.
 +
 +
 ==== TProcessOptions ==== ==== TProcessOptions ====
  
Ligne 109: Ligne 128:
 Wait for the process to terminate before returning. Wait for the process to terminate before returning.
 === poUsePipes === === poUsePipes ===
-Use pipes to redirect ​standard ​input and output.+Utilisez les ''​pipes''​ pour rediriger les entrées et sorties ​standard
 + 
 +Utiliser cette option si l'on veut récupérer le texte généré par l'​application.
 === poStderrToOutPut === === poStderrToOutPut ===
 Redirect standard error to the standard output stream. Redirect standard error to the standard output stream.
 === poNoConsole === === poNoConsole ===
-Do not allow access to the console ​window for the process ​(Win32 ​only)+Ne pas autoriser l'​accès à la fenêtre de la console ​pour le processus ​(Win32 ​uniquement).\\ 
 +N'​affiche pas la console.
 === poNewConsole === === poNewConsole ===
 Start a new console window for the process (Win32 only) Start a new console window for the process (Win32 only)
Ligne 125: Ligne 147:
 Do not follow processes started by this process (Win32 only) Do not follow processes started by this process (Win32 only)
 === poDetached === === poDetached ===
 +ToDo !!!
 === poPassInput === === poPassInput ===
 Pass standard input handle on to new process Pass standard input handle on to new process
 === poRunIdle === === poRunIdle ===
 +ToDo!!!
  
 ===== TProcessUTF8 ===== ===== TProcessUTF8 =====
Ligne 151: Ligne 175:
   * [[prog:​lazarus:​classes:​tasyncprocess|Page de TAsyncProcess]]   * [[prog:​lazarus:​classes:​tasyncprocess|Page de TAsyncProcess]]
   * [[https://​lazarus-ccr.sourceforge.io/​docs/​lcl/​asyncprocess/​tasyncprocess.html]]   * [[https://​lazarus-ccr.sourceforge.io/​docs/​lcl/​asyncprocess/​tasyncprocess.html]]
- 
-===== Astuces ===== 
-==== Trouver le filename complet d'une commande ==== 
-Exemple : trouver le filename complet de la commande ''​php''​. 
- 
-Grâce a la fonction ''​FindFilenameOfCmd(ProgramFilename:​ string): string''​ qui se trouve dans l'unit ''​UTF8Process''​ ([[#​tprocessutf8|voir ci-dessus]]) 
- 
-''​FindFilenameOfCmd('​php'​)''​ => ''​C:​\Program Files\php\php-7.3.6\php.exe''​ 
- 
-Cette fonction utilise les fonctions suivantes : ''​fileutil:​FindDefaultExecutablePath''​ qui parcours tous les PATHs a la recherche de ce fichier (grâce à  ''​fileutil:​SearchFileInPath''​). 
- 
-<note tip>​N'​aurait t'il pas été plus facile d'​utiliser ''​JwaPsApi:​GetProcessImageFileName''​ ou ''​QueryFullProcessImageNameA''​ en passant le Handle du TProcess pour retrouver ce nom de fichier ???</​note>​ 
- 
  
  
-===== Sources ​et Ressources=====+====== Sources ​Ressources=====
 +  * [[prog:​lazarus:​cas:​processus:​processus]] (Page locale)
   * [[https://​wiki.freepascal.org/​Executing_External_Programs/​fr|Executing External Programs/​fr]]   * [[https://​wiki.freepascal.org/​Executing_External_Programs/​fr|Executing External Programs/​fr]]
   * [[prog:​lazarus:​classes:​tasyncprocess|Page de TAsyncProcess]]   * [[prog:​lazarus:​classes:​tasyncprocess|Page de TAsyncProcess]]
   * [[https://​lazarus-ccr.sourceforge.io/​docs/​lcl/​asyncprocess/​tasyncprocess.html]]   * [[https://​lazarus-ccr.sourceforge.io/​docs/​lcl/​asyncprocess/​tasyncprocess.html]]
 +  * [[https://​docs.microsoft.com/​en-us/​windows/​win32/​api/​processthreadsapi/​nf-processthreadsapi-terminateprocess|Doc TerminateProcess @ Windows]]