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)
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 .