Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multitasking
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00659181
Message ID:
00664181
Views:
32
Looks good. Also, you can set if a window appears or not by adjusting the START structure like so:
START = this.long2str(68) + REPLICATE(CHR(0), 40)+this.long2str(1)+this.long2str(0)+REPLICATE(CHR(0), 16)
in this case, it's completely hidden (0 -SW_HIDE)
Here's an example to start IIS:
File2Run = "net start W3SVC" + CHR(0)

	RetCode = CreateProcess(0, File2Run, 0, 0, 1, ;
		NORMAL_PRIORITY_CLASS, 0, 0, @START, @process_info)

	* Unable to run, exit now.
	IF RetCode = 0
		THIS.cError="Error occurred. Error code: "+ GetLastError()
		RETURN THIS.cError
	ENDIF

	* Extract the process handle from the
	* PROCESS_INFORMATION structure.
	hProcess = this.str2long(SUBSTR(process_info, 1, 4))

	DO WHILE .T.
	* Use timeout of TIMEOUT_INTERVAL msec so the display
	* will be updated. Otherwise, the VFP window never repaints until
	* the loop is exited.
		IF WaitForSingleObject(hProcess, WAIT_INTERVAL) != WAIT_TIMEOUT
			EXIT
		ELSE
			Sleep(0)
		ENDIF
	ENDDO


	* Close the process handle afterwards.
	RetCode = CloseHandle(hProcess)
>Hi,
>I finally had to use CreateProcess & WaitForSingleObject DLLs.
>Program1 uses CreateProcess to start Program2 and the two continue asynchronously.
>When Program1 has finished its job, it uses WaitForSingleObject DLL to make sure that Program2 is over and then it terminates.
>
>Everything seems to be working fine on small volumes of data. I would really appreciate it if you could verify this code for me.
>
>Ria
>
>Program1 Code:
>
>#DEFINE NORMAL_PRIORITY_CLASS 32
>#DEFINE IDLE_PRIORITY_CLASS 64
>#DEFINE HIGH_PRIORITY_CLASS 128
>#DEFINE REALTIME_PRIORITY_CLASS 1600
>
>* Return code from WaitForSingleObject() if
>* it timed out.
>#DEFINE WAIT_TIMEOUT 0x00000102
>
>#DEFINE WAIT_OBJECT_O 0x000000
>
>* This controls how long, in milli secconds, WaitForSingleObject()
>* waits before it times out. Change this to suit your preferences.
>#DEFINE WAIT_INTERVAL 0x00000FFFF &&5000
>#DEFINE INFINITE 0x00000FFFF
>
>.........................
>
>RetCode = CreateProcess(0, File2Run, 0, 0, 1, ;
> NORMAL_PRIORITY_CLASS, 0, 0, @start, @process_info)
>
>* Extract the process handle from the
>* PROCESS_INFORMATION structure.
>hProcess = str2long(SUBSTR(process_info, 1, 4))
>
>.........................
>* Program1 continues
>
>.........................
>
>WaitForSingleObject(hProcess,INFINITE)
>
>*End Program1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform