Solved

Instance of another application

Posted on 1998-06-15
3
125 Views
Last Modified: 2010-05-03
I know how to check the instance of the application that is running.
But how can you check the instance of another application that
might be running?  I have tried to use the Windows API call to
FindWindow(...,...) but I may be calling it wrong.  If someone could
point me in the right direction I would appreciate it.

Thanks -- jr
0
Comment
Question by:jrmcg
3 Comments
 
LVL 6

Expert Comment

by:anthonyc
Comment Utility
FindWindow(0, "WindowCaptionHere")
0
 
LVL 2

Author Comment

by:jrmcg
Comment Utility
I tried FindWindow(0,"CAPTION") already.  I think
my problem is in the declaration of the function.
Is there anything wrong with this?:::

Declare Function FindWindow Lib "User32" Alias
"FindWindowA" (ByVal lpClassName As String,
ByVal lpCaption As String) As Long

I tried without the alias and it wouldn't compile.
Maybe the return type is wrong?  I know the
Function returns an hWnd but the compiler
did not like that either.

Thanks -- jr
0
 
LVL 2

Accepted Solution

by:
peterwest earned 30 total points
Comment Utility
Hi there,

The correct declaration for the API call is:

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

The function returns a long value that is the hWnd of the object found - so basically, if it doesn't return 0 then another instance of that window is already running....

Pete

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now