vbhargav80
asked on
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!
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!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Again sorry for getting back so late. I've been really busy. Thanks for all your help though
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.