Coba gunakan ini:
procedure ExecuteAndWait(FileName : String; WindState : Word);
var aAppName : array[0..512] of char;
StartupInfo : TStartupInfo;
ProcessInfo : TProcessInformation;
begin
StrPCopy(aAppName,FileName);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := WindState;
CreateProcess(nil, aAppName, nil, nil, false, CREATE_NEW_CONSOLE or
NORMAL_PRIORITY_CLASS, nil, nil,
StartupInfo, ProcessInfo);
if (ProcessInfo.hProcess = 0) then
begin
raise Exception.Create('Fail to create process.');
end
else
begin
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
TerminateProcess(ProcessInfo.hProcess,0);
end;
HTH,
Sintar.
=========
----- Original Message -----
From: "devy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, 12 November 2003 8:39 AM
Subject: [Delphindo] Wait until Winexec selesai ??
> Terima kasih atas saran para delphier semua atas pertanyaan asaya
terdahulu.
> Dan memang solusi itu berjalan dgn baik, TAPI, sekarang timbul masalah
> baru, yaitu
>
> saat WinExec(perintah_delete, SW_SHOWNORMAL); dijalankan
> maka program tidak menunggu apakah printah DOS tersebut sudah selesai atau
> belum, dan program langsung menjalankan perintah berikutnya
>
> Bagaimana caranya agar program menunggu Winexec / perintah DOS selesai
> mengcopy file baru menjalankan proses berikutnya ??
> Atau apakah ada parameter yang dapat saya gunakan sebagai indikasi Winexec
> selesai dijalankan ??
> syntax program saya adalah
>
> winexec_i := WinExec(pchar(scom), SW_NORMAL);
>
> if winexec_i = 0 then
> Memo1.Lines.Add('The system is out of memory or resources. ');
>
> if winexec_i = ERROR_BAD_FORMAT then Memo1.Lines.Add('The .EXE file
> is invalid (non-Win32 .EXE or error in .EXE image');
> if winexec_i = ERROR_FILE_NOT_FOUND then Memo1.Lines.Add('The specified
> file was not found.');
> if winexec_i = ERROR_PATH_NOT_FOUND then
> Memo1.Lines.Add('ERROR_PATH_NOT_FOUND ');
> if winexec_i > 31 then
> begin
> ------------
> Proses file yang sudah dicopy ...................
> ----------
> end;
>
> Regards
> Devy Arifianto
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/i7folB/TM
---------------------------------------------------------------------~->
Berlangganan: [EMAIL PROTECTED]
Stop Berlangganan: [EMAIL PROTECTED]
Keluhan Milis(Unbouncing,spam,dll): [EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/