How can I have a program detect that it is already running and if it is it needs to send a string of data to the already running copy and close itself.
Dont know how to do either of these any pointers in the right direction would help
Thanks
How can I have a program detect that it is already running and if it is it needs to send a string of data to the already running copy and close itself.
Dont know how to do either of these any pointers in the right direction would help
Thanks
For the first part, I'd do;
Or, something along those lines... Add the code before the window is created,Code:HWND find; find = FindWindow(NULL, InsertNameHere); if (find) { MessageBox(NULL,"terminating request... this program is currently in use.", "Permission Denied",MB_TOPMOST); PostQuitMessage(0); return 0; //stop duplicate versions from launching }
that way it doesn't interfer with the initial launch of your program.
What if another window shares the same title bar? What if you wanted your title bar to change (ie, "MyTextEditor - [ filename.myext ]" )
CreateMutex seems to be how it's done, and allows you full control over your title bar.
(GIYF)
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
I understand your argument, though I've never run across that problem -
Thanks, create mutex works great.
I use file mapping instead of a mutex, I have posted the code previously. Both are valid methods.
To send info between processes I use a broadcast message, search on HWND_BROADCAST .
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill