Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems checking running process
Message
From
14/02/2005 15:19:01
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Problems checking running process
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Novell 4.x
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00986772
Message ID:
00986772
Views:
46
Hello,

I try to check for another running process, in this case refox.exe to terminate before going on with the code, but I don't get any further.

This is what I came up with so far, trying to instantiate a modal form with a timer checking the currently active window and releaseing the form as soon as the active window has changed. However, the active window is empty.
! /N c:\refox_8\refox.exe 
loWaitWindow = CREATEOBJECT("WaitForm","Refox")
loWaitWindow.SHOW(1)

DEFINE CLASS WaitForm AS FORM
	ALWAYSONTOP = .T.
	cProcessName = ""
	PROCEDURE INIT
		LPARAMETERS tcProcessName
		THIS.cProcessname = UPPER(tcProcessname)
		DECLARE INTEGER GetActiveWindow IN Win32API
		DECLARE INTEGER GetWindow IN Win32API;
			INTEGER hwnd, INTEGER dflag
		DECLARE INTEGER GetWindowText IN Win32API ;
			INTEGER hwnd, STRING @lptstr, INTEGER cbmax
	ENDPROC
	ADD OBJECT tmr AS Timer WITH ;
			ENABLED = .T., ;
			INTERVAL = 1000
	PROCEDURE tmr.Timer
		THISFORM.WaitForProcess()
	ENDPROC
	PROCEDURE WaitForProcess
		*
		lnhWnd = GetActiveWindow()
		lctitle_bar = SPACE(200) + CHR(0)
		lntext_len = GetWindowText(lnhwnd, @lctitle_bar, 200)
		*
                *-- UPPER(LEFT(lctitle_bar, lntext_len)) is always empty!
		IF THIS.cProcessname $ UPPER(LEFT(lctitle_bar, lntext_len))
			*-- still running.
		ELSe
			THIS.Tmr.Interval = 0
			THIS.Release()
		ENDIF	
	ENDPROC
ENDDEFINE
I can't figure out why this fails, any ideas?
Christian Isberner
Software Consultant
Next
Reply
Map
View

Click here to load this message in the networking platform