Different event object behavior in Windows XP and Windows 7

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) {
  // there is an instance already running
  SetEvent(hSingleInstance);// let know the 1st instance that we are trying to start
  CloseHandle(hSingleInstance);
  return 0; // exit the program
}
else {
  // this is the 1st instance
  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? , , , ?

+3
2

, , - . , XP.

+1

, . , , , , , , , , , .

Vista ; - "" ; , , . - , / .

, , , , : , OpenEvent : , , , , .

, ( ), : , .

+1

All Articles