[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 154
  • Last Modified:

Refer to a specific instance of an application

Dear Experts,

i have 2 developed 2 different applications that interface to a host system. I can have both my applications running at the same time so i'll need to launch the interface to the host application twice as well.

Now i know both my applications to know which instance of the host applications it launched. How can this be done?

Please Help!
0
vbhargav80
Asked:
vbhargav80
  • 2
  • 2
2 Solutions
 
jkaiosCommented:
Did you mean HOW TO CHECK IF THE SAME APPLICATION HAS ALREADY LOADED?

If App.PrevInstance Then
  'Do something...
End If
0
 
ddepastinoCommented:

Private Sub Form_Load
   If App.PrevInstance Then
     me.caption = me.caption & " (Instance 2)"
   End If
end sub

The only problem that will occur is if you launch a 3rd instance, it would also show up as "<AppCaption> (Instance 2)".

To overcome that you would need to send a command line parameter when launching all of them and put this in form load:

Private Sub Form_Load

if command > "" then
   me.caption = me.caption & " (Instance " & command & ")"
end if

end sub

Then from a command line/script/application you would launch them with their instance number:

C:\FakeProgram.exe 1
C:\FakeProgram.exe 2
C:\FakeProgram.exe 3

Both of these are workarounds to enumerating the computer processes at startup and generating an instance number based on the count of processes matching the application path + 1.  If you go this route you are looking at either WMI or API for a solution.

0
 
vbhargav80Author Commented:
Sorry for replying back so late.

I think i did ot make my question clear enough.

I have 2 different applications. App A and App B. Both of these can run at the same time.

When these applications start (A and B) they both launch another application C.

So when A and B are both running there will be 2 instances of C. Both A and B need to get data from application C. But how can i determine which application C was launched by A or B?

0
 
ddepastinoCommented:
The example above would display the difference in the two apps in the title bar of AppC.

This would be the code for AppC Main/Form_Load:

if command > "" then
   me.caption = "AppC (Launched By: " & Command & ")"
end if


And then launch AppC from AppA/AppB with different command line paramaters:

AppA:
Shell "C:\AppC.exe ApplicationA"

AppB:
Shell "C:\AppC.exe ApplicationB"

That make any sense?
0
 
vbhargav80Author Commented:
Again sorry for getting back so late. I've been really busy. Thanks for all your help though
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now