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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| unit Unit1;
//Fichier stub de Shell Command Extractor, la variable 'Command' est definie par l'utilisateur grace a l'interface fournie. Il en est de meme pour la variable 'Ghost'.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Exemod, ShellApi, strutils;
type
TSCEForm = class(TForm)
CmdLabel: TLabel;
Param1Label: TLabel;
Param2Label: TLabel;
Param3Label: TLabel;
Param4Label: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
SCEForm: TSCEForm;
implementation
{$R *.dfm}
procedure TSCEForm.FormCreate(Sender: TObject);
var
Command:String;
Ghost:String;
begin
//Rendre le contenu de Ghost et Command modifiable de facon externe grace a ExeMod
ExtractFromExe('nil', Command);
ExtractFromExe('ghostnil', Ghost);
//Afficher la commande
CmdLabel.Caption := Command;
//Verifier si les parametres contiennent des espaces
Param1Label.Caption := ParamStr(1);
Param2Label.Caption := ParamStr(2);
Param3Label.Caption := ParamStr(3);
Param4Label.Caption := ParamStr(4);
If AnsiContainsStr(ParamStr(1), ' ') Then Param1Label.Caption := '"'+Param1Label.Caption+'"';
If AnsiContainsStr(ParamStr(2), ' ') Then Param2Label.Caption := '"'+Param2Label.Caption+'"';
If AnsiContainsStr(ParamStr(3), ' ') Then Param3Label.Caption := '"'+Param3Label.Caption+'"';
If AnsiContainsStr(ParamStr(4), ' ') Then Param4Label.Caption := '"'+Param4Label.Caption+'"';
//Si le mode Ghost est choisi, verifier le nombre de parametres et lancer la commande de facon silencieuse
If Ghost = 'True' Then
begin
Application.ShowMainForm := False;
If Param1Label.Caption = '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command), nil, SW_HIDE);
If Param1Label.Caption <> '' Then If Param2Label.Caption = '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command+' '+Param1Label.Caption), nil, SW_HIDE);
If Param1Label.Caption <> '' Then If Param2Label.Caption <> '' Then If Param3Label.Caption = '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command+' '+Param1Label.Caption+' '+Param2Label.Caption), nil, SW_HIDE);
If Param1Label.Caption <> '' Then If Param2Label.Caption <> '' Then If Param3Label.Caption <> '' Then If Param4Label.Caption = '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command+' '+Param1Label.Caption+' '+Param2Label.Caption+' '+Param3Label.Caption), nil, SW_HIDE);
If Param1Label.Caption <> '' Then If Param2Label.Caption <> '' Then If Param3Label.Caption <> '' Then If Param4Label.Caption <> '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command+' '+Param1Label.Caption+' '+Param2Label.Caption+' '+Param3Label.Caption+' '+Param4Label.Caption), nil, SW_HIDE);
Application.Terminate;
end
//Si Ghost n'a pas ete active par l'utilisateur, lancer la commande de facon visible
Else
begin
If Param1Label.Caption = '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command), nil, SW_SHOWNORMAL);
If Param1Label.Caption <> '' Then If Param2Label.Caption = '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command+' '+Param1Label.Caption), nil, SW_SHOWNORMAL);
If Param1Label.Caption <> '' Then If Param2Label.Caption <> '' Then If Param3Label.Caption = '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command+' '+Param1Label.Caption+' '+Param2Label.Caption), nil, SW_SHOWNORMAL);
If Param1Label.Caption <> '' Then If Param2Label.Caption <> '' Then If Param3Label.Caption <> '' Then If Param4Label.Caption = '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command+' '+Param1Label.Caption+' '+Param2Label.Caption+' '+Param3Label.Caption), nil, SW_SHOWNORMAL);
If Param1Label.Caption <> '' Then If Param2Label.Caption <> '' Then If Param3Label.Caption <> '' Then If Param4Label.Caption <> '' Then ShellExecute(Handle, 'open', 'cmd.exe', Pchar('/K '+Command+' '+Param1Label.Caption+' '+Param2Label.Caption+' '+Param3Label.Caption+' '+Param4Label.Caption), nil, SW_SHOWNORMAL);
end;
end;
//Fermer la console qui s'ouvre avec le programme quand on quitte SCE
procedure TSCEForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
h: HWND;
begin
h := FindWindow(nil, 'C:\WINDOWS\system32\cmd.exe');
if h <> 0 then PostMessage(h, WM_CLOSE, 0, 0);
end;
end. |
Partager