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 [28/02/2021 19:37] thierry [Trouver le filename complet d'une commande] |
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 ==== | ||
+ | === poRunSuspended === | ||
+ | Start the process in suspended state. | ||
+ | === poWaitOnExit === | ||
+ | Wait for the process to terminate before returning. | ||
+ | === poUsePipes === | ||
+ | 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 === | ||
+ | Redirect standard error to the standard output stream. | ||
+ | === poNoConsole === | ||
+ | Ne pas autoriser l'accès à la fenêtre de la console pour le processus (Win32 uniquement).\\ | ||
+ | N'affiche pas la console. | ||
+ | === poNewConsole === | ||
+ | Start a new console window for the process (Win32 only) | ||
+ | === poDefaultErrorMode === | ||
+ | Use default error handling. | ||
+ | === poNewProcessGroup === | ||
+ | Start the process in a new process group (Win32 only) | ||
+ | === poDebugProcess === | ||
+ | Allow debugging of the process (Win32 only) | ||
+ | === poDebugOnlyThisProcess === | ||
+ | Do not follow processes started by this process (Win32 only) | ||
+ | === poDetached === | ||
+ | ToDo !!! | ||
+ | === poPassInput === | ||
+ | Pass standard input handle on to new process | ||
+ | === poRunIdle === | ||
+ | ToDo!!! | ||
===== TProcessUTF8 ===== | ===== TProcessUTF8 ===== | ||
Ligne 125: | Ligne 173: | ||
</code> | </code> | ||
===== TAsyncProcess ===== | ===== 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]]) | + | ====== Sources & Ressources====== |
- | + | * [[prog:lazarus:cas:processus:processus]] (Page locale) | |
- | ''FindFilenameOfCmd('php')'' => ''C:\Program Files\php\php-7.3.6\php.exe'' | + | * [[https://wiki.freepascal.org/Executing_External_Programs/fr|Executing External Programs/fr]] |
- | + | * [[prog:lazarus:classes:tasyncprocess|Page de TAsyncProcess]] | |
- | Cette fonction utilise les fonctions suivantes : ''fileutil:FindDefaultExecutablePath'' qui parcours tous les PATHs a la recherche de ce fichier (grâce à ''fileutil:SearchFileInPath''). | + | * [[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]] | |
- | <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===== | ||
- | * [[https://wiki.freepascal.org/Executing_External_Programs/fr|Executing External Programs/fr]] | ||