Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ShellExecute WaitForSingleObject IsRunning(GeorgeTasker)
Message
From
22/03/2004 10:42:24
 
 
To
22/03/2004 08:21:45
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00887963
Message ID:
00888529
Views:
51
Thanks for the ideas Alan, but Adobe fails to open then. I did get it working though:
llacordok = ExeWait(lcshort,hdir+xacordform+'.xfdf',lcpath)

*--Uses GetExitcodeProcess instead of waitforsingleobject
PROCEDURE  ExeWait (lcApp, lcCmdLine, lcdir)
IF _VFP.AutoYield = .F.
	llsetback = .T.
ELSE
	llsetback = .F.
ENDIF
 _VFP.AutoYield = .T.
#DEFINE INFINITE  0xFFFFFFFF
LOCAL lcStartupInfo, lcProcInfo, hProcess, ;
	lnPrio, lnIBelieve1
lnIBelieve1 = 1   && Don't remember what that was
lnPrio = 32 && Priority of Process=Normal
lcStartupInfo = CHR(68) + REPLI(CHR(0), 67)
lcProcInfo = REPLI(CHR(0), 16)
IF CreateProcess(0, m.lcApp+" "+m.lcCmdLine+CHR(0), 0,0,;
		m.lnIBelieve1, m.lnPrio,;
		0, 0, @lcStartupInfo, @lcProcInfo) <> 0
	* process and thread handles returned in ProcInfo structure
	hProcess = buf2dword(SUBSTR(lcProcInfo, 1,4))
	hThread = buf2dword(SUBSTR(lcProcInfo, 5,4))
	* waiting until the termination of the program
	DOEVENTS
	DO WHILE .T.
		exitcode = 0					&& initialize return value to 0
		= GetExitCodeProcess(hProcess, @exitcode)	&& try to obtain process exit code
		IF exitcode # 259				&& not still busy
			EXIT							&& fall out of loop
		ENDIF
		= Sleep (100)					&& wait .1 seconds
	ENDDO
	= CloseHandle(hThread)
	= CloseHandle(hProcess)
ELSE
	IF llsetback
		 _VFP.AutoYield = .F.
	ENDIF
	RETURN .F.
ENDIF
IF llsetback
	 _VFP.AutoYield = .F.
ENDIF
RETURN
>Tracy,
>
>I think the problem is that you still have two handles open at the moment that Acrobat Reader is closed. If you close the handles immediately after creating the process, then everything closes properly when the reader is exited by the user.
>
>As you are not using the handles it is OK to close them. Your procedure becomes:-
>
>
>PROCEDURE  RunAndWait (lcApp, lcCmdLine, lcdir)
>#DEFINE INFINITE  0xFFFFFFFF
>LOCAL lcStartupInfo, lcProcInfo, hProcess, ;
>	lnPrio, lnIBelieve1
>lnIBelieve1 = 1   && Don't remember what that was
>lnPrio = 32 && Priority of Process=Normal
>lcStartupInfo = CHR(68) + REPLI(CHR(0), 67)
>lcProcInfo = REPLI(CHR(0), 16)
>IF CreateProcess(0, m.lcApp+" "+m.lcCmdLine+CHR(0), 0,0,;
>		m.lnIBelieve1, m.lnPrio,;
>		0, 0, @lcStartupInfo, @lcProcInfo) <> 0
>	* process and thread handles returned in ProcInfo structure
>	hProcess = buf2dword(SUBSTR(lcProcInfo, 1,4))
>	hThread = buf2dword(SUBSTR(lcProcInfo, 5,4))
>	= CloseHandle(hThread)
>	= CloseHandle(hProcess)
>	* waiting until the termination
>	= WaitForSingleObject(hProcess, INFINITE)
>ELSE
>	RETURN .F.
>ENDIF
>RETURN
>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform