|
-
October 4th, 1999, 01:32 AM
#1
prevInstance
How can I define the previous instance of my application in VC6. The member m_hPrevInstance in 32 bit app is always set to NULL. The method FindWindow looks bad to me, because I don't want use window title to search.
-
October 4th, 1999, 09:50 PM
#2
Re: prevInstance
And you are right.
There is many other ways to check if your app is running. For example you can create memory file and check for it’s presence. If it exists refuse to run another instance.
Named pipes will also do.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
November 2nd, 1999, 04:31 AM
#3
Re: prevInstance
You can use Mutex for that.
First, in InitInstance() you should create it:
HANDLE test=CreateMutex(NULL,TRUE,"MyMutex");
If then you run another app copy, this call will
return ERROR_INVALID_HANDLE and GetLastError() will return ERROR_ALREADY_EXISTS value.
Don't forget to close mutex after program termination in ExitInstance():
CloseHandle(test);
Never say never.
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
|