|
-
September 8th, 1999, 02:55 AM
#1
not loaded two time!!!
I want a application which will not be loaded if it is already loaded.
(how I can determnine if I an in the second "instance" of this application ?
(hPrevInstance from Win31)?)
-
September 8th, 1999, 03:41 AM
#2
Re: not loaded two time!!!
Here is one option, though i bet there are better ones. You could keep a flag in the registry stating if there is a program of your running currently, then every program can check the flag and if it TRUE than it should close itself.
-----------------------------------------
Rotem Bentzur
[email protected]
Feel free to send questions.....
-
September 8th, 1999, 03:56 AM
#3
Re: not loaded two time!!!
The are some ways, just now I remember two of them:
1. Use FindWindow
HWND hExist=FindWindow (0,szYourWindowTitle);
if (hExist)
return FALSE;
2.Create Mutex like this:
CreateMutex(NULL,TRUE,szAnyText); // mutex will be automatically deleted when process ends.
BOOL bAlreadyRunning = (GetLastError() == ERROR_ALREADY_EXISTS);
if(bAlreadyRunning){
char szMsg [256];
strcpy (szMsg, "Application already started");
m_pMainWnd->MessageBox (szMsg, "BLA_BLA_BLA",
MB_OK | MB_ICONWARNING | MB_APPLMODAL);
return FALSE;
}
The code above shouldbe placed in InitInstance.
Good luck,
Oleg.
-
September 8th, 1999, 04:26 AM
#4
Re: not loaded two time!!!
Ok then, how can you then open up any files passed as parameters in the first instance.
-
September 8th, 1999, 04:38 AM
#5
Re: not loaded two time!!!
Hi,
it's shown in the MSDN. Search for the article ID Q141752.
Martin
-
September 8th, 1999, 04:51 AM
#6
Re: not loaded two time!!!
Please, can you describe your problem in more details. What do you want as the result?
Oleg.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|