PDA

Click to See Complete Forum and Search --> : how i connect my progs?


TalZ
Jun 21st, 2000, 09:40 PM
if i have a program that hide her window...
now the user run another copy of her.
i don't want the other copy to run(thats i know how to do)
but i want that the hide window will know that the user try
to run another copy of her and respond...

somebody have and idea how i do it???

kb244
Jun 21st, 2000, 10:19 PM
If I correctly understand your post, you want only a single instance of the program to run at a time, no other copies running on the computer, check this vb-world tips section, I am positive there is something there about only one instance of your program.

TalZ
Jun 21st, 2000, 10:29 PM
no ...
i mean that i want that the hide program to know when the user try to run another copy (how to prevent the other copy to run , this i know!).

but thanks anyway...

kb244
Jun 21st, 2000, 11:24 PM
I see, with the normal only run one thing, the copy thats new knows it's a second copy then closes, but the original copy will not know another has been opened. hmm, maybe a timmer checking the the classname, or a DDE session to tell the original copy before closing the new.

kedaman
Jun 26th, 2000, 05:58 AM
If "the other app" is yours, you may put a code that does it instead by itself:

if app.previnstance then unload me

Also it's preferable to put this in a sub main so you wont even need to load any forms

if app.previsntance then exit sub

kb244
Jun 26th, 2000, 06:04 AM
but he wants his currently opened program to detect the attempt to run a second copy.

kedaman
Jun 26th, 2000, 06:48 AM
Sorry i missunderstood, well you can check for the running window classname, using findwindow api, also if you don't have a window in that app you could enumerate the the processes

TalZ
Jun 26th, 2000, 03:30 PM
i have a question...

i think i can do it like this:
when the prog start she write a file with her DC, when you run antoer copy it checks the app.previnstance and if it's True then he get the DC (from the file) of the run copy and just show it (if it hide...) or send it any other message and kill it self.

i try it...

parksie
Jun 26th, 2000, 03:34 PM
I would suggest using the window handle (HWND) rather than the device context, as VB has a habit of reorganising those.