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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is a program running?

Status
Not open for further replies.

gvt

Programmer
Jul 19, 2000
14
SE
I would like to to find out if, for instance, Explorer or Netscape is already running. I have heard that&nbsp;&nbsp;FindWindow API function can be used to search for the Window Title specified but the problem is that the Window Title can change depending on the site or file name which is open. Is there a way to go around this? <br>I have also heard that something called &quot;App&quot;&nbsp;&nbsp;can be used instead but unfortunately I can not find any example about this App on VB help topics. <br>If you know anything about these or any other way to find out if a program is already running please let me know. <br><br>Thank you for your time and effort. <br><br>&nbsp;&nbsp;&nbsp;Vio
 
The App object can be use to find out if there is another copy of *your* program already running, you can use it like this to make sure that users only run one copy of your VB application:<br><br>If App.Previnstance Then<br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Already Running&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;End<br>End If<br><br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
I found this example in the VB 6 help which may be of use to you as it does not use the window title to find a running process.<br><br>Sub DetectExcel() as Boolean<br>' Procedure detects a running Excel and returns true.<br>Dim hWnd As Long<br>' If Excel is running this API call returns its handle.<br>&nbsp;&nbsp;&nbsp;hWnd = FindWindow(&quot;XLMAIN&quot;, 0)<br>&nbsp;&nbsp;&nbsp;DetectExcell = (hWnd &lt;&gt; 0) ' because hWnd is zero if excell is not running.<br>End Sub<br><br>By the way - there's now a forum specifically for VB Win32API questions.<br><br>Hope these examples are of help to you<br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top