In my C ++ / winapi program, I use an event object to determine if an instance of my application is running so as not to start the second instance.
But at the same time, I want to allow the launch of several instances of the program if they are running using a different user account. For instance. using the runas command. (That is: for each user account, only one instance can be launched at a time)
I am using code that looks like this:
HANDLE hSingleInstance=OpenEvent(EVENT_MODIFY_STATE,FALSE,
"Local\\SingleInstanceEventName");
if(hSingleInstance!=NULL) {
SetEvent(hSingleInstance);
CloseHandle(hSingleInstance);
return 0;
}
else {
hSingleInstance=CreateEvent(NULL,FALSE,FALSE, "Local\\SingleInstanceEventName");
}
It works as expected in XP - I can only run one instance using the same user account, and I can run multiple instances using multiple user accounts.
Windows 7 OpenEvent() "" , . - ( ).
, Windows 7?
, , , ?