Lahey Support
08-15-2003, 01:33 AM
Hello again:
This is my question from last week recycled. Sorry to be monotonous.
I'm continuing to work on making a SYSTEM() call which runs in a
minimized window. The best I can come up with now is based on the
WINAPI routines:
ModuleHandle=GetModuleHandleA(carg(NULL))
ShellHandle = ShellExecuteA(&
carg(ModuleHandle), &
carg("open"), &
carg("d:winapi estcall.bat"), &
carg("test argument"), &
carg("d:winapi"), &
carg(sw_Minimize))
retval = WaitForSingleObject(carg(ShellHandle),carg(infinit e))
The steps are (1) get the current window handle, (2) shell to a
minimized window which runs the batch file, and (3) wait for the process
to complete. In order to simulate a call to a program which might run
for a while, I use the following testcall.bat:
@echo off
if exist testcall.out del testcall.out
echo Here we are waiting for response.
pause
echo Test call complete! >testcall.out
The problem is that the WaitFor.. routine comes back with an error code
(retval=-1), and when I then retrieve the error code with:
errorcode = GetLastError()
it turns out that returned error code depends on whether I have compiled
with NT4 (errorcode=6=invalid handle) or W2K
(errorcode=5=access_denied).
Does anyone have any tricks for getting this to work? I've attached a
small zip file containing my complete program if anyone is interested.
Thanks,
Tom
--
Thomas F. Rutherford Phone (303) 492-5169
Department of Economics Fax (303) 492-8960
University of Colorado [address removed]
Boulder, CO 80309-0256 http://debreu.colorado.edu/
This is my question from last week recycled. Sorry to be monotonous.
I'm continuing to work on making a SYSTEM() call which runs in a
minimized window. The best I can come up with now is based on the
WINAPI routines:
ModuleHandle=GetModuleHandleA(carg(NULL))
ShellHandle = ShellExecuteA(&
carg(ModuleHandle), &
carg("open"), &
carg("d:winapi estcall.bat"), &
carg("test argument"), &
carg("d:winapi"), &
carg(sw_Minimize))
retval = WaitForSingleObject(carg(ShellHandle),carg(infinit e))
The steps are (1) get the current window handle, (2) shell to a
minimized window which runs the batch file, and (3) wait for the process
to complete. In order to simulate a call to a program which might run
for a while, I use the following testcall.bat:
@echo off
if exist testcall.out del testcall.out
echo Here we are waiting for response.
pause
echo Test call complete! >testcall.out
The problem is that the WaitFor.. routine comes back with an error code
(retval=-1), and when I then retrieve the error code with:
errorcode = GetLastError()
it turns out that returned error code depends on whether I have compiled
with NT4 (errorcode=6=invalid handle) or W2K
(errorcode=5=access_denied).
Does anyone have any tricks for getting this to work? I've attached a
small zip file containing my complete program if anyone is interested.
Thanks,
Tom
--
Thomas F. Rutherford Phone (303) 492-5169
Department of Economics Fax (303) 492-8960
University of Colorado [address removed]
Boulder, CO 80309-0256 http://debreu.colorado.edu/