?
Solved

API 32bits

Posted on 1998-12-07
4
Medium Priority
?
257 Views
Last Modified: 2010-05-03
How do I know when one application is runing two times?
I have the next code in 16 bits:

' Get the Handle for the RTT module
var1 = GetModuleHandle("trm0001.exe")
' Get the Reference Count of the TR module
l_int_ref_count_rtt_module = GetModuleUsage(var1)
' If an instance of SPP module is already running
If var1 > 1 Then
  MsgBox "Can not start more than one instance of TR system."
  End
End If
0
Comment
Question by:ogarcial
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1448576
IF you have the window's handle, you can simply check if the window exists using FindWindow.

Tell me if that's what you need,

---
Regards
Postel Mike
0
 
LVL 1

Expert Comment

by:Chamberlain
ID: 1448577
Are you trying to stop your program from running more than one instance?  If they try to start another it just transfers to the first?  If that's the case, I can tell you how to do it without any API, strictly in VB.
0
 

Accepted Solution

by:
Acid_Buzz earned 100 total points
ID: 1448578
If you want to prevent user to load 2 instance on local pc you don't need any API call to do it you juste have to use

App.PrevInstance

This VB Function return a boolean.

True : If another instance of your application is allready running on the same computer
False : if no other instance of your apps is find.

Acid Buzz.

0
 
LVL 1

Expert Comment

by:Chamberlain
ID: 1448579
Nice how Acid Buzz jumps in and trys to answer the question without even knowing the question by feeding off of other people's responses.  IF you are trying to do, as I posed above, which is only allow one instance of YOUR VB app to run then yes, App.PrevInstance will tell you if there is another instance but it doesn't solve the problem of moving focus to the first instance.  To do that use AppActivate.  AppActivate takes the caption of the main form.  Since you have are calling it from within a new instance, you have to change it's caption otherwise it will only activate itself..  Here is some code.


Sub Form_Load()
  If App.PrevInstance then
    Dim OldCaption as String
    OldCaption = Caption
    Caption = ""
    AppActivate OldCaption
    End
  End If
End Sub

That's the complete answer that I promised to give (if it is what you are looking for.)  Not the partial answer that Acid Buzz threw in there trying to leach points.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

764 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