Re: Using a Global Mutex
From: Pavel Lebedinsky (m_pll_at_hotmail.com)
Date: 05/21/04
- Next message: Chuck Chopp: "Re: Idle time in a T.S. session - how to get it?"
- Previous message: Pavel Lebedinsky: "Re: Stackwalk64 problems"
- In reply to: Viviana Vc: "Using a Global Mutex"
- Messages sorted by: [ date ] [ thread ]
Date: 21 May 2004 13:23:10 -0700
SeCreateGlobalPrivilege is also in Win2K SP4 but you
shouldn't need it because as far as I can tell
it only applies to memory mapped files (a.k.a "sections"),
not things like events and mutexes.
"Intitial system session" is session 0, where services
run. On current operating systems it is also the session
where the first interactive user is logged on, but this
will probably change in Longhorn, so you shouldn't
depend on it.
There's a session id column in task manager that you
can use to determine what sessions your processes run in
(on Win2K it's only present if you have Terminal Services
installed).
Viviana Vc <vcotirlea@hotmail.com> wrote:
> Hi all,
>
> I have an application App1, that after doing some stuff starts App2.
> Both are per user applications.
> Now, on an XP with FUS enabled or an Win2k with Terminal Services, there
> can be at the same time more than one user logged in, and for these
> situations I would like to do the following:
> a)- for user1, App1 starts and then it starts App2 (normal situation)
> b)- for user2, I have to find out in App1 if the App2 is already running
> for another user, because in that case I have to do some stuff
>
> For doing the step b) I was thinking to do:
> - App2 when starts creates a mutex with "Global\\..." (to be in the
> global namespace)
> - App1 when starts checks if that mutex already exists (i.e:
> if(CreateMutex(NULL, TRUE, MyAppOneInstanceMutex))
> {if(ERROR_ALREADY_EXISTS == GetLastError()) // the mutex was already
> created...}) and in this way App1 can be sure that on that machine there
> is already a running App2 (for that user or another one).
>
> Questions:
> 1) Would this be a nice solution to detect from App1 that App2 is
> already running?
> 2) In MSDNL is written: "Starting with Windows Server 2003, the creation
> of a global section from a session other than the initial system session
> (where clients run) is a privileged operation. Because of this, an
> application running in an arbitrary Terminal Server session must have
> SeCreateGlobalPrivilege enabled in order to create a global section
> successfully. Note that the privilege check is limited to the creation
> of section objects, and does not apply to opening existing ones. For
> example, if a service or the system creates a global section, any
> process running in any session can access that section provided that the
> user has the necessary access."
>
> Can somebody explain what that means? What does "from a session other
> than the initial system session (where clients run)" mean? Which is
> initial system session? The first logged in user?
> In my case this issue can affect my App2 which will try to create a
> global mutex (and it might be that user1 doesn't have my app installed,
> so the first time when my app will be run can be when user2 logs in, so
> the global mutex will be just then created)? If yes, how could I set the
> SeCreateGlobalPrivilege privilege?
>
> Thanks in advance,
> Viv
- Next message: Chuck Chopp: "Re: Idle time in a T.S. session - how to get it?"
- Previous message: Pavel Lebedinsky: "Re: Stackwalk64 problems"
- In reply to: Viviana Vc: "Using a Global Mutex"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|