Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CreateProcess Problems
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00852013
Message ID:
01131263
Views:
17
>Hi Tracy,
>
>May be try
>lcdir = SYS(5)+SYS(2003)
>
>Also this code works slightly better (modified recently):
>PROCEDURE RunAndWait (lcApp, lcCmdLine)
>#DEFINE START_INFO_SIZE 68
>#DEFINE INFINITE  0xFFFFFFFF
>
>	DECLARE INTEGER CreateProcess IN kernel32;
>		STRING lpAppName, STRING lpCmdLine, INTEGER lpProcAttr,;
>		INTEGER lpThrAttr, INTEGER bInhHandles, INTEGER dwCrFlags,;
>		INTEGER lpEnvir, STRING lpCurDir, ;
>		STRING @lpStInfo, STRING @lpProcInfo
>
>	LOCAL cStartupInfo, cProcInfo, hProcess, hThread
>	cStartupInfo = PADR(Chr(START_INFO_SIZE), START_INFO_SIZE, Chr(0))
>	cProcInfo = Repli(Chr(0), 16)
>
>	IF CreateProcess(lcApp, lcCmdLine, 0,0,0,0,0,;
>		SYS(5)+SYS(2003), @cStartupInfo, @cProcInfo) <> 0
>
>		* process and thread handles returned in ProcInfo structure
>		hProcess = buf2dword(SUBSTR(cProcInfo, 1,4))
>		hThread = buf2dword(SUBSTR(cProcInfo, 5,4))
>
>		* waiting until the termination
>		= WaitForSingleObject(hProcess, INFINITE)
>
>		= CloseHandle(hThread)
>		= CloseHandle(hProcess)
>	ELSE
>		? "Error code:", GetLastError()
>	ENDIF
>
Do you mean
* waiting until the termination
= WaitForSingleObject(hProcess, INFINITE)

is better than
doevents
		do while .t.
			ExitCode = 0               && initialize return value to 0
			= GetExitCodeProcess(m.hProcess, @ExitCode)   && try to obtain process exit code
			if m.ExitCode # 259            && not still busy
				exit                     && fall out of loop
			else
				lnCount = m.lnCount + 1
				if m.lnCount < 45
*
				else
					exit
				endif
			endif
			= Sleep (100)               && wait .1 seconds
		enddo
		= Sleep(1000)
Are they equavalent?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform