Board index » cppbuilder » Ensuring single occurance with CreateProcessAsUser and FUS

Ensuring single occurance with CreateProcessAsUser and FUS


2008-04-19 09:53:52 AM
cppbuilder48
Hi guys - hopefully the final post for a few days - I think I nearly have my
system working.
I have one last questions, maybe someone could give me a few ideas. I'm
just looking for some design suggestions.
The background to my problem is as follows. I currently have a GinaStub
that runs under the context of the LocalSystem, in time though, this will be
replaced with a service. In either case, the system controls access to a
given computer and controls what can be done on that computer, based on the
logged on user.
When a user logs on, a system tray icon / application is launched based on
the [HKLM] Run registry key. When a user double-clicks on this icon, an IPC
message is sent to the GinaStub / Service which then uses
CreateProcessAsUser to launch a configuration application. This system all
works fine and seems to hold water with Fast-User switching.
However, I now have a small issue. Firstly, I want to ensure that only one
occurrence of this Control application is launched per logged on user. As
it stands, if a double-click on the icon more than once, I get another
occurrence of the control app launched. I don't think that I can use the
normal mutex system for ensuring single occurrence because this mutex may
have been created by a control app on another users desktop.
Does this make any sense? Does anyone have any suggestions?
Cheers, Mike C
 
 

Re:Ensuring single occurance with CreateProcessAsUser and FUS

Mike Collins wrote:
Quote
I don't think that I can use the
normal mutex system for ensuring single occurrence because this mutex may
have been created by a control app on another users desktop.

Does anyone have any suggestions?
Named Mutex, on the user's and your gina's name.
MutexName = MyServiceName + User.Name;
 

Re:Ensuring single occurance with CreateProcessAsUser and FUS

"Mike Collins" <its@TheBottomOfThePost>wrote in message
Quote
I want to ensure that only one occurrence of this Control application
is launched per logged on user. As it stands, if a double-click on the
icon more than once, I get another occurrence of the control app
launched. I don't think that I can use the normal mutex system for
ensuring single occurrence
Yes, you can.
Quote
because this mutex may have been created by a control app on
another users desktop.
But that mutex would only exist in that user's session only, as long as you
are not creating the mutex in the "Global" namespace, otherwise it would be
shared amongst multiple user sessions.
Gambit
 

{smallsort}

Re:Ensuring single occurance with CreateProcessAsUser and FUS

Sorry for the late response - been in hospital have my knee fixed up so
hobbling around on crutches. lol
So what you are basically saying is that when you create a mutex, it is only
valid for the current user / the environment / desktop that it is created
in? Is this correct?
Do I simply place "Local\" in front of the mutex name to ensure that it is
not a global mutex?
Thanks again
Mike
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote


 

Re:Ensuring single occurance with CreateProcessAsUser and FUS

"Mike Collins" <its@TheBottomOfThePost>wrote in message
Quote
So what you are basically saying is that when you create a mutex, it
is only valid for the current user / the environment / desktop that it
is created in? Is this correct?
By default, yes. You have to put it into the "Global\" namespace if you
want to share it amongst multiple user sessions.
Quote
Do I simply place "Local\" in front of the mutex name to ensure
that it is not a global mutex?
Yes. But only on XP and later. Namespaces are ignored on Win2000, and '\'
is an illegal character in kernel name for OSs prior to that.
Gambit