Solved

Instance of another application

Posted on 1998-06-15
3
127 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
ID: 1463351
FindWindow(0, "WindowCaptionHere")
0
 
LVL 2

Author Comment

by:jrmcg
ID: 1463352
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
ID: 1463353
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

821 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