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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running VC application "ONCE" 1

Status
Not open for further replies.

azamK

Programmer
Aug 12, 2001
10
IR
Hi
I build an application in vc++ and I want that 'one' instance of application can be runned,in a time .that means that when I run the application, then any instance of this application can't be run in that time.
How can do this?

thanks
Azam Keypour
 
One way is to use CreateMutex.

#include <windows.h>

/* In real code, this should be a unique identifier */
#define MUTEX_NAME &quot;MYPROGRAM&quot;

int main(void)
{
CreateMutex(NULL, FALSE, MUTEX_NAME);
if (GetLastError() != 0) {
/* Instance of this program is already running */
return EXIT_FAILURE;
}
/* ... */
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top