Différences
Ci-dessous, les différences entre deux révisions de la page.
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:38] thierry [poDetached] |
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 132: | Ligne 151: | ||
Pass standard input handle on to new process | Pass standard input handle on to new process | ||
=== poRunIdle === | === poRunIdle === | ||
+ | ToDo!!! | ||
===== TProcessUTF8 ===== | ===== TProcessUTF8 ===== | ||
Ligne 155: | 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]] | ||