Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

This InnoSetup plugin can check for running processes and/or loaded modules, also can execute console program, and returns his output in real time to the CallBack function.

Notifications You must be signed in to change notification settings

Wilenty/InnoSetup-plugin-ExecDos-and-CheckRunning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InnoSetup plugin ExecDos and CheckRunning

Latest Version Total Downloads Latest Release Downloads

Short info about my plugin:
This plugin (DLL) was created for InnoSetup which can execute console program, and returns his output in real time to the CallBack function.
Also, my plugin can check for running processes and/or loaded modules like a DLL and other dynamically loaded libraries.

Functions/procedures ending with A are ANSI, but ending with W are Unicode.
Functions/procedures without A or W as last letter they are common, that means they can be used in ANSI or Unicode.


Functions list:
TExecOutCallBackA = procedure(const OutputA: PAnsiChar);
TExecOutCallBackW = procedure(const OutputW: WideString);

Function IsModuleLoadedA(const ModuleNameOrFullPathA: PAnsiChar): Boolean;
Function IsModuleLoadedW(const ModuleNameOrFullPathW: WideString): Boolean;

Function IsProgramRunningA(const FileNameOrFullPathA: PAnsiChar): Boolean;
Function IsProgramRunningW(const FileNameOrFullPathW: WideString): Boolean;

Function ExecDosA(const FileNameOrFullPathA, CommandLineA, WorkingDirectoryA: PAnsiChar; const ShowWindow: Integer; ExecOutCallBackA: TExecOutCallBackA; const Wait: Boolean): DWORD;
Function DosWriteInputA(const InputA: PAnsiChar): Boolean;

Function ExecDosA2W(const FileNameOrFullPathA, CommandLineA, WorkingDirectoryA: PAnsiChar; const ShowWindow: Integer; ExecOutCallBackW: TExecOutCallBackW; const Wait: Boolean): DWORD;

Function ExecDosW(const FileNameOrFullPathW, CommandLineW, WorkingDirectoryW: WideString; const ShowWindow: Integer; ExecOutCallBackW: TExecOutCallBackW; const Wait: Boolean): DWORD;
Function DosWriteInputW(const InputW: WideString): Boolean;

Function Wait4ProcessExitCode(const ProcessID: DWORD): DWORD;

Function IsProcessExists(const ProcessID: DWORD): Boolean;

Function GetHWNdPID(const hWnd: HWND): DWORD;

Function GetPIDpathA(const ProcessID: DWORD): PAnsiChar;
Function GetPIDpathW(const ProcessID: DWORD): WideString;

Function GetPIDhWND(const ProcessID: DWORD): HWND;

Function GetProgramInfoA(const FileNameOrFullPathA: PAnsiChar; out ProcessID: DWORD): PAnsiChar;
Function GetProgramInfoW(const FileNameOrFullPathW: WideString; out ProcessID: DWORD): WideString;

Function GetModuleInfoA(const ModuleNameOrFullPathA: PAnsiChar; out IsLoaded: DWORD): PAnsiChar;
Function GetModuleInfoW(const ModuleNameOrFullPathW: WideString; out IsLoaded: DWORD): WideString;

Functions ExecDos* works in two ways. Namely, if you specify last parameter "Wait: Boolean" to true it waits for the program, and when it ends returns it's exit code.
But, if you specify last parameter "Wait: Boolean" to false, it returns program ID, so you can do what you want in the script and check if the process still exists by function IsProcessExists. Or, you can wait for the program exit code by function Wait4ProcessExitCode, if you needs it.

Note: you can use functions DosWriteInput* only if you specify callback function in parameter "ExecOutCallBack*: TExecOutCallBack*", other way it do nothing and always returns false.

Function ExecDosA2W was created to execute programs from InnoSetup [Run] section for Unicode scripts, because InnoSetup prototype function must use parameters as a String. It converts ANSI characters to Unicode and calls ExecDosW function.

Functions: GetProgramInfoA, GetProgramInfoW, GetModuleInfoA and GetModuleInfoW returns location of the program/module. GetProgramInfo* returns process ID in ProcessID variable, but GetModuleInfo* returns 0/1 in variable IsLoaded.


Bonus functions:
Function CreateConsole(): Bool;

Function SetConsoleTitleA(const TitleA: PAnsiChar): Bool;
Function SetConsoleTitleW(const TitleW: WideString): Bool;

Function SetConsoleBufferSize(SizeX, SizeY: SmallInt): Bool;

Function SetConsoleTextColors(BackColor, TextColor: Word): Bool;

Function SetConsoleColors(BackColor, TextColor: Word): Bool;

Function WriteConsoleA(const InputA: PAnsiChar): Bool;
Function WriteConsoleW(const InputW: WideString): Bool;

Function ClearConsole(): Bool;

Function DestroyConsole(): Bool;

Note 1: you must always execute DestroyConsole() function at the end, if you used CreateConsole() function before.

Note 2: you can use only one console at the same time.

Note 3: if console still exists, you must use flag "ShellExec" in [Run] section for other console programs, without this flag executed console programs will be redirected to the console you created, and your installer will hangs out.

Console and Text colors are written in the *.isi (InnoSetup include) files as "BackColorName" for first parameter, and "TextColorName" for second parameter.
Please don't mix the BackColor and TextColor between parameters, because they are differ.
If you don't need to change one of the colors, you can use OldColor constant ($FF) as a parameter, it will use last used color.


I also created InnoSetup include (*.isi) files with all functions described to use, separatelly for ANSI/Unicode (ExecDosAndCheckRunning.isi) for choose manually. But ANSI/Unicode with auto-detection (ExecDosAndCheckRunningA-Wauto.isi), these functions without A or W as last letter.

So, you just need to include the file in you script by '#Include "ExecDosAndCheckRunning.isi"' (without single quote characters) at the beginning of the script for manually use the ANSI/Unicode (A/W) functions, or use the '#Include "ExecDosAndCheckRunningA-Wauto.isi"' file with ANSI/Unicode auto-detection (these functions without A or W as last letter).


In compiled examples I showed how to use it. Scripts included with needed files to compile it.

About

This InnoSetup plugin can check for running processes and/or loaded modules, also can execute console program, and returns his output in real time to the CallBack function.

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published