CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2006
    Location
    Bangalore, India
    Posts
    18

    Single instance app and multi logons

    Hi all,

    I have a single instance application which is started automatically
    on user logons.

    Single instance is maintained using a global mutex lock.

    Now the problem i m facing when running on multi logon machines is as follows.


    UserA logs in --> single.exe is started

    UserB logs in --> single.exe detects another instance and exits.

    UserA logs out --> running single.exe exits.

    Now there is no instance of single.exe is running on that computer.

    I can not make this program a windows service since it should be
    running as any logged on user as owner.

    Do you have any ideas to solve this problem ?

    Cheers

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Single instance app and multi logons

    Simple solution...incorporate the user name into the mutex unique name...

  3. #3

    Re: Single instance app and multi logons

    (Since you mentioned multi logon, this should work for you - Local\ prefix on mutex name) But...

    What OS targets are you targeting?

    Is it XP and newer only?

    Because I believe XP uses terminal services to implement fast user switching.

    If that is the case:

    Quote Originally Posted by MSDN
    The name can have a "Global\" or "Local\" prefix to explicitly create the object in the global or session name space
    http://msdn.microsoft.com/library/de...reatemutex.asp

    However...

    Quote Originally Posted by MSDN
    Windows 2000: If Terminal Services is not running, the "Global\" and "Local\" prefixes are ignored. The remainder of the name can contain any character except the backslash character.

  4. #4
    Join Date
    Mar 2006
    Location
    Bangalore, India
    Posts
    18

    Re: Single instance app and multi logons

    Thanks for the suggestions.

    But that does not completely solve my problem. I can not run multiple instances in any case.

    In the suggested method each user will have one instance of the app running right ?

    Or may be I did not understand.


    Cheers

  5. #5
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Single instance app and multi logons

    Quote Originally Posted by JamesSchumacher
    What OS targets are you targeting?
    Well...if he is running Windows 2000, he wouldn't have any problems since Windows 2000 didn't implement fast user switching...

  6. #6
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Single instance app and multi logons

    Quote Originally Posted by aneesh.joy
    But that does not completely solve my problem. I can not run multiple instances in any case.
    Well...then I don't understand the problem in the first place. If you always run only one instance the method you are using (creating a unique mutex) is fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured