[DUG] CreateProcess
Robert martin
rob at wildsoft.co.nz
Wed Oct 25 15:37:17 NZDT 2006
Hi
I am trying to use create process to run a batch file. The batch file
exports a MySQL DB to a file. The batch file runs but the file is 0kb
however if run that batch file normally (not from CreateProcess) the
file is correctly created (about 2MB). The code I am using is shown
below, does anyone have any idea as to what I am doing wrong?
var
proc_info : TProcessInformation;
startinfo : TStartupInfo;
ExitCode : longword;
begin
Result := False;
// Initialize the structures
FillChar(proc_info, sizeof(TProcessInformation), 0);
FillChar(startinfo, sizeof(TStartupInfo), 0);
startinfo.cb := sizeof(TStartupInfo);
// Attempts to create the process
if (CreateProcess(Nil,
pChar('MySQLExport.bat'),
nil,
nil,
false,
NORMAL_PRIORITY_CLASS,
nil,
pChar(AppDir),
startinfo,
proc_info) <> False) then begin
// Process created, now s wait till it ends...
WaitForSingleObject(proc_info.hProcess, INFINITE);
GetExitCodeProcess(proc_info.hProcess, ExitCode);
CloseHandle(proc_info.hThread);
CloseHandle(proc_info.hProcess);
Sleep(5000); //Wait 5secs just to allow any windows cleanup or
other to finish
if (FileExists(AppDir + BASE_FILE) = True) then begin
if (CreateZipFile = True) then begin
Result := True;
end;
end;
end;
end;
--
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd
More information about the Delphi
mailing list