Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems checking running process
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Problems checking running process
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Novell 4.x
Database:
Visual FoxPro
Divers
Thread ID:
00986772
Message ID:
00986772
Vues:
47
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform