Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to prevent an application from loading more than once?

Status
Not open for further replies.

reneb

Programmer
Aug 8, 2000
43
US
I wrote a simple dialog based application with some initial help from the AppWizard. The question is, how do I prevent my application from beign loaded after it has already been loaded once? In other words I only want one instance of the application to run at a time. Any suggestions? Thank you in advanced. [sig][/sig]
 
Check the FindWindow API function in your MSDN documentation. You can use this one to check if another window with the same title as yours is active at the moment. Hope this helps. I will explain no further because it is rather simple to use.

dex
[sig][/sig]
 
Another way is to create a named mutex object in InitInstance() and return if creation fails.
This will ensure that the application will be instantiated only once.
[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top