본문으로 바로가기

Exec / ShellExec

category Package/innosetup 2019. 12. 10. 22:33
728x90

Inno Setup에서 프로그램을 실행 시키는 간단한 방법

 

▶ 기본 구조

function Exec(const Filename, Params, WorkingDir: String; 
const ShowCmd: Integer; const Wait: TExecWait; var ResultCode: Integer): Boolean;
  • Filename : 따옴표 하지 말고 풀 경로를 적을 것
  • Params : 파라미터 정보
  • WorkingDir : 해당 프로그램을 실행 할 경로, 공란이여도 됨
  • ShowCmd : SW_SHOW / SW_SHOWNORMAL / SW_SHOWMAXIMIZED / SW_SHOWMINIMIZED / SW_SHOWMINNOACTIVE / SW_HIDE 중 선택
  • Wait : ewNowait / ewWaitUntilTerminated / ewWaitUntilIdle 중 선택
  • ResultCode : 에러 메세지를 표시하고 싶다면 이 항목에 Description을 적으면 됨

 

※ 실행이 성공 할 경우 True가 Return되고 실패할 경우 False가 Return됨

※ exe 또는 batch 파일이 아닐 경우 ShellExec 함수를 사용 할 것

function ShellExec(const Verb, Filename, Params, WorkingDir: String; const ShowCmd: Integer;
const Wait: TExecWait; var ErrorCode: Integer): Boolean;
  • Verb : Open 또는 Print를 많이 사용하는데 그중에서도 Open을 일반적으로 사용함 (공란도 가능)

▷예시 (exec)

var
  ResultCode: Integer;
begin
  // Launch Notepad and wait for it to terminate
  if Exec(ExpandConstant('{win}\notepad.exe'), '', '', SW_SHOW,
     ewWaitUntilTerminated, ResultCode) then
  begin
    // handle success if necessary; ResultCode contains the exit code
  end
  else begin
    // handle failure if necessary; ResultCode contains the error code
  end;
end;

▷예시 (shellexec)

var
  ErrorCode: Integer;
begin
  if not ShellExec('open', 'chrome.exe', 'http://test.com',
  '', SW_HIDE, ewNoWait, ErrorCode ); then
  begin
    
  end;
end;

'Package > innosetup' 카테고리의 다른 글

innosetup page 종류  (0) 2019.12.13
StringChange / StringChangeEx  (0) 2019.12.11
Radio Button  (0) 2019.07.28
64bit 32bit packaging  (0) 2019.07.28
Innosetup 기본 포멧  (0) 2019.07.28