Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

process running in background

Status
Not open for further replies.

kenndot

Programmer
May 15, 2001
316
US
is there an API function that can return whether a specific process is running? here's why...

let's say there's a problem w/an application and a user tries to open it but it never opens, but the process starts in the background and of course they don't know that. then they try to open it again and again and again... until they have 25 instances of this process running... is there a function or api call to use that can check what processes are in that task manager list? I know about the getWindow api but I don't want the window because i'm theorizing that the program window never opened...

thanks!
 
See the information on Enumerate in my response to Chris in thread184-449938. I actually use a variant of the sample code to fire up a copy SETI@home ( if I find it's not running due to connection or site problems. While this is the reverse of whatr you want, I'm sure you'll see the possibilities.

Rick
 
kenndot

As an alternative to Rick's suggestion of Enumerate, try the following :-

lnHand = IsRunning([Acrobat Reader])
IF lnHand # 0
[tab]* code
ENDI

* Function: IsRunning (Modified form George Tasker's original)
* Syntax: lVar = IsRunning([application])
* Generic routine to check if a given application is running on the user's system

FUNCTION IsRunning
LPARAMETER lcTitle && All or part of the app's window title

DECLARE INTEGER BringWindowToTop IN Win32API ;
[tab]INTEGER hWnd

DECLARE INTEGER GetActiveWindow IN Win32API

DECLARE INTEGER GetWindow IN Win32API ;
[tab]INTEGER hWnd,;
[tab]INTEGER nType

DECLARE INTEGER GetWindowText IN Win32API ;
[tab]INTEGER hWnd ,;
[tab]STRING @cText ,;
[tab]INTEGER nType

hNext = GetActiveWindow() && Current app's window
* Iterate through the open windows
DO WHILE hNext # 0
[tab]cText = REPLICATE(CHR(0),80)
[tab]GetWindowText(hNext,@cText,80) && Get window title
[tab]IF UPPER(ALLTRIM(lcTitle)) $ UPPER(cText)
[tab]* parameter text is present in window title
[tab][tab]RETURN hNext
[tab]ENDIF
[tab]hNext = GetWindow(hNext,2) && Next window
ENDDO
* Required window not found
RETURN 0
FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top