올라온 예제를 그대로 적용해 보았는데 잘 안되요.알려 주세요,...
=> GetExitCodeProcess(ProcessInfo.hProcess,Result);
윗부분에서 계속 에러가 걸리고
잘 안되요..
___________________________________________________________
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ShellApi;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function WinExecAndWait32(FileName : PChar; CommandLine : PChar;
Visibility : Integer) : Integer;
var
zAppName:array[0..512] of char;
zCurDir:array[0..255] of char;
WorkDir:ShortString;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
StrCopy(zAppName, FileName);
StrCat(zAppName, CommandLine);
GetDir(0, WorkDir);
StrPCopy(zCurDir, WorkDir);
FillChar(StartupInfo, Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes}
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) then { pointer to PROCESS_INF }
Result := -1
else begin
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess,Result); //
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ShellExecute(Handle,'open','zsetup.exe','','',SW_SHOWNORMAL);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
//여기서 1초 간격으로 폼 생성시 실행 했던 "'zsetup.exe"가
종료 되었는지 체크하고 종료 되었으면 다음 작업 실행 하고파
NextProcess();
end;
end.
불쑥 멜을 보내 죄송합니다.
델파이 Q&A에 글올리신걸보니 제가 원하는 문제를 먼저 올리셨더군요.
저도 SellExecute로 종료시점을 알고싶은데 방법이 없나요?
저보다 먼저 경험하셨기에 방법이 알고 계시리라 생각이들어서
글을 올립니다.
CreateProcess로 실행을 하면 도스창이 뜨기 때문에 ShellExecute함수로
실행할려고 합니다.
방법을 아시거나 CreateProcess함수에도 sw_hide라는 파라메터를 쓸수 있는지
궁금합니다.
멜부탁드립니다. 죄송합니다.
봉길천 wrote:
> 올라온 예제를 그대로 적용해 보았는데 잘 안되요.알려 주세요,...
> => GetExitCodeProcess(ProcessInfo.hProcess,Result);
> 윗부분에서 계속 에러가 걸리고
> 잘 안되요..
> ___________________________________________________________
>
> unit Unit1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
> StdCtrls, ShellApi;
>
> type
> TForm1 = class(TForm)
> Button1: TButton;
> procedure Button1Click(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.DFM}
> function WinExecAndWait32(FileName : PChar; CommandLine : PChar;
> Visibility : Integer) : Integer;
> var
> zAppName:array[0..512] of char;
> zCurDir:array[0..255] of char;
> WorkDir:ShortString;
> StartupInfo:TStartupInfo;
> ProcessInfo:TProcessInformation;
> begin
> StrCopy(zAppName, FileName);
> StrCat(zAppName, CommandLine);
> GetDir(0, WorkDir);
> StrPCopy(zCurDir, WorkDir);
> FillChar(StartupInfo, Sizeof(StartupInfo),#0);
> StartupInfo.cb := Sizeof(StartupInfo);
> StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
> StartupInfo.wShowWindow := Visibility;
> if not CreateProcess(nil,
> zAppName, { pointer to command line string }
> nil, { pointer to process security attributes}
> nil, { pointer to thread security attributes }
> false, { handle inheritance flag }
> CREATE_NEW_CONSOLE or { creation flags }
> NORMAL_PRIORITY_CLASS,
> nil, { pointer to new environment block }
> nil, { pointer to current directory name }
> StartupInfo, { pointer to STARTUPINFO }
> ProcessInfo) then { pointer to PROCESS_INF }
> Result := -1
> else begin
> WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
> GetExitCodeProcess(ProcessInfo.hProcess,Result); //
> end;
> end;
> procedure TForm1.FormCreate(Sender: TObject);
> begin
> ShellExecute(Handle,'open','zsetup.exe','','',SW_SHOWNORMAL);
> end;
> procedure TForm1.Timer1Timer(Sender: TObject);
> begin
> //여기서 1초 간격으로 폼 생성시 실행 했던 "'zsetup.exe"가
> 종료 되었는지 체크하고 종료 되었으면 다음 작업 실행 하고파
>
> NextProcess();
> end;
>
> end.