Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 To: Markus Raab
  Where is Markus Raab?
 Bad Kötzting
 Germany
 Markus Raab
 Tags
Subject: RE: Control Process
Thread ID: 201250 Message ID: 201255 # Views: 40 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Win32API programming
Date: Saturday, November 01, 2008 2:33:51 PM         
   


> Hello,
>
>
> in my program (let's call: MAIN.EXE) i start a second programm (let's call: second.exe) with the run command. The problem now is, that my user can start my programm (=MAIN) several times. The second program can take about 2 minutes to finish - if the user starts my program MAIN during this 2 minutes again, the second program (SECOND) will also start for a second time, third time and s.o. ....
>
> If i'm looking in the windows task manager, i can see the processes - how can i check, if the process SECOND.EXE is still running ?
>
> Many thanks
>
>
> Markus
Welcome

I give you a small script who can returns you a the answer.
put your exec name in "yourexe" (juststem only)
LOCAL loWMI, lcQuery, loResult, loProcess
loWMI = GetObject("winmgmts://")
lcQuery = "select * from win32_process where name='"+yourexe+"'"
loResult = loWMI.ExecQuery(m.lcQuery)

if loResult.count=0
*well ..Run your programm run/n 
else
oo="Application running"
messagebox(yourexe+" is already running !",0+32+4096,oo)
endi


if you want to kill your application "yourexe" if running terminate the script above with this
FOR EACH loProcess IN loResult
if loProcess.name="yourexe"
   loProcess.Terminate(0)
endi	
NEXT


You can also use windows API (FindWindowEx).se this News2News link where you must know the title of your window appplication.

http://www.news2news.com/vfp/?function=-1&example=45

You must modify it a bit for testing if your window title is in the cursor.
count for  "Yout application exact title" $ wintitle to xrun
if xrun=0
*application not running
else
*application running
endi

you can also see this link in the same subject
http://www.ml-consult.co.uk/foxst-11.htm
Regards
Yousfi Benameur



COMPLETE THREAD
Control Process Posted by Markus Raab @ 11/1/2008 2:15:00 PM
RE: Control Process Posted by Frank Cazabon @ 11/1/2008 2:23:17 PM
RE: Control Process Posted by Yousfi Benameur @ 11/1/2008 2:33:51 PM
RE: Control Process Posted by Markus Raab @ 11/2/2008 10:19:31 AM
RE: Control Process Posted by Yousfi Benameur @ 11/2/2008 1:35:56 PM
RE: Control Process Posted by Carlos Alloatti @ 11/1/2008 5:14:12 PM