Subject Re: Two problems/questions with GBAK
Author csswa
This delphi procedure allows you to execute a program and to wait
until it's finished.

Regards,
Andrew Ferguson
-- If they ask, tell them it was Andrew, then run.



function WinExecAndWait32(FileName: string; Visibility: Integer):
dWord;
var
zAppName: array[0..512] of Char;
zCurDir: array[0..255] of Char;
WorkDir: string;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin
StrPCopy(zAppName, FileName);
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
Result := -1 { pointer to PROCESS_INF }
else
begin
WaitforSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, Result);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
end;
end;





--- In ib-support@y..., Joe Martinez <joe@j...> wrote:
> > I'm not using the return value from GBak. I ask for help with this
> > ERRORLEVEL code too, but - sorry - I don't remember what where
the results.
>
> This would be ideal. If I could just get a YES/NO answer if it was
successful,
> that would be good.
>
> > Also I had some problems to get an ASCII file with the error
messages, but
> > Carlos Macao give me this help. If you want all error messages in
a file I
> > can give this to you.
>
> Yes, I would appreciate this greatly! Also, if you don't mind
sharing your
> parsing logic, it would help a lot.
>
> Another question:
>
> Are you using WinExec to call GBAK? I have the problem that
WinExec returns
> immediately after it calls GBAK, even though GBAK is still
running. How do you
> know when GBAK is done?
>
> Thanks,
> Joe