unit Shared;

interface

uses
 Windows, SysUtils;

function RunSWParam(CommandLine, Params: string; Show_Cmd:Integer) : LongBool;
function GetWindir(ReturnTempDir : Boolean) : string;

implementation


function RunSWParam(CommandLine, Params: string; Show_Cmd:Integer) : LongBool;
var
 StartupInfo : TStartupInfo;
 ProcessInfo : TProcessInformation;
 ExecCmd : string;
begin
 FillChar(StartupInfo,Sizeof(StartupInfo),#0);
 StartupInfo.cb := Sizeof(StartupInfo);
 StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
 Startupinfo.wShowWindow := Show_Cmd;

 if Length(CommandLine) = 0 then
  begin
  Result := False;
  Exit;
  end;

  //ExecCmd := GetParam(CommandLine,False)+' '+GetParam(CommandLine,true);
  ExecCmd := CommandLine +' '+ Params;
  
  Result := CreateProcess(nil,
            PChar(ExecCmd), nil, nil, False,
            CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,
            nil, nil, StartupInfo, ProcessInfo);
end;

function GetWindir(ReturnTempDir : Boolean) : string;
var
  a : Array[0..MAX_PATH] of char;
begin
  GetWindowsDirectory(a, sizeof(a));
  if ReturnTempdir = True then Result := (StrPas(a)) + '\TEMP\' else
  Result := (StrPas(a)) + '\';
end;

end.
