Click here to Skip to main content
Licence 
First Posted 7 Jan 2003
Views 42,099
Bookmarked 18 times

To create single instance of application

By | 7 Jan 2003 | Article
Simple way to create single instance of application.

to create single instance of application at any time

this code helps to run only one instance of application

//just create mutex with valid name in InitInstance () method of MFC application

HANDLE hmutex = CreateMutex(NULL,FALSE,"JUSTTOCHECK");

// then check for that name whether it already exists or not by following code,

// if exists release mutex and return false otherwise just release the mutex

{

if ( hmutex && GetLastError () == ERROR_ALREADY_EXISTS)

ReleaseMutex (hmutex);

return FALSE;

}

ReleaseMutex (hmutex) ;

when you run the application it opens the window, keeping that open if you try to run the same application it won't

creates window.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Sadanand

Systems Engineer

India India

Member

Sadanand P G graduate in BE Comp Science.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralThis solves only a very small part of the problem and... PinmemberAndreas Saurwein21:58 7 Jan '03  
GeneralRe: This solves only a very small part of the problem and... PinmemberDaniel Turini22:52 7 Jan '03  
GeneralRe: This solves only a very small part of the problem and... PinmemberLarry Antram23:22 7 Jan '03  
GeneralRe: This solves only a very small part of the problem and... PinmemberAndreas Saurwein0:54 8 Jan '03  
GeneralRe: This solves only a very small part of the problem and... PinmemberMach0056:29 2 Apr '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 8 Jan 2003
Article Copyright 2003 by Sadanand
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid