Re: Windows Service - Fast User Switching - Find Active Desktop Problem

From: Eduardo Francos (efrancos_at_wanadoo.fr)
Date: 04/19/05

  • Next message: Brandon Jiang: "system logs off even my wlxloggedoutsas return WLX_SAS_ACTION_LOGON"
    Date: Tue, 19 Apr 2005 10:47:50 +0200
    
    

    Peter Boulton wrote:
    > Eduardo Francos wrote on 18/04/2005 07:12:
    >
    >> Peter Boulton wrote:
    >>
    >>> Hi,
    >>>
    >>> I am writing a Windows Service, which is allowed to interact with the
    >>> desktop. (I realise that this is not recommended, but it is
    >>> currently a constraint.) It needs to post advice windows on the
    >>> desktop of whoever is logged in. With fast user switching this could
    >>> be any one of any number of concurrent sessions. My service needs to
    >>> post the windows to the active session, so that the active user can
    >>> interact with it.
    >
    >
    > <snipped>
    >
    >>
    >>
    >> AFAIK services are always run in the console terminal session, Session
    >> 0. Addressing WinSta0 from a service will then always point to that
    >> session.
    >>
    >> Running a program within the security context of the user can be done
    >> simple by adding a UI client program in the Run key of HKLM or HKCU,
    >> then use whatever IPC scheme that suits your needs to communicate with
    >> the service.
    >> You may use the WTSRegisterSessionNotification related API group to
    >> know when user sessions are activated/deactivated so the service knows
    >> which client to notify. Alternatively the service can notify all
    >> connected clients and have the client UI decide whether to interact
    >> with its user or not.
    >>
    >> For further information you can refer to "How To Design a Service to
    >> Interact with Multiple User Sessions"
    >> http://support.microsoft.com/default.aspx?scid=kb;en-us;308403
    >>
    >> or "Fast User Switching: Issues for Assistive Technology Vendors"
    >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/accessibility.asp
    >>
    >>
    >>
    >>
    >> Eduardo
    >
    >
    >
    > Thanks for the reply. So, are you saying what I want to do is
    > impossible? That is, launch a process in the currently logged on user's
    > context from my service, on the desktop of whoever has sent the ipc via
    > a named pipe to my service?
    >
    > If so, how do I get this, given the named pipe handle from the calling
    > process?
    >
    > Please be gentle with me - this stuff is very new to me! Code example
    > would be very much appreciated!
    >
    > Thanks.
    >
    > Pete

    No, I'm not saying it's impossible, only that the approach may be harder
    to implement due to the constrains on services.

    Concerning the communication between the client (running in a user
    session) and the service I'm quoting from the first article reference I
    gave you on my previous posting
    (http://support.microsoft.com/default.aspx?scid=kb;en-us;308403)

    =======================
    The server process (your service) then communicates with the appropriate
    client through some means of interprocess communication to tell the
    client when to display the GUI. The client, in turn, communicates the
    results of the user's interaction back to the service so that the
    service can act appropriately.

    Because there will be multiple clients running on the system (a separate
    client running in each user session), the service must have a
    well-defined method to distinguish the clients. The most common method
    to distinguish clients is to name the channel of communication by using
    the client's session ID.

    For example, if the client is running in session 4, the client may
    create a pipe whose name is a concatenation of an unpublished GUID,
    followed by "Channel_4". The client will then pass its session ID to the
    service (perhaps by connecting to another pipe that is created by the
    service) so that the service knows to connect to the "Channel_4" pipe.
    The client can obtain its session ID by calling
    WTSQuerySessionInformation() with WTSSessionId as the information class.
    =======================

    For code examples on how to use named pipes you can refer to the MSDN
    article "Named Pipe Instances" at
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/named_pipe_instances.asp

    Eduardo


  • Next message: Brandon Jiang: "system logs off even my wlxloggedoutsas return WLX_SAS_ACTION_LOGON"

    Relevant Pages

    • Re: [PHP] Re: a question on session ID and security
      ... hash key" to the client when it doesn't need it? ... But by doing that you're exposing how your app validates the authentication key, leaving it open to being transferred to another machine. ... tutorial on PHP session security is helpful. ...
      (php.general)
    • RE: ISA 2004 Firewall client
      ... The green arrow only shows up when the client needs to initiate a ... firewall session. ... Part 3: I want to explain How the logs and sessions work: ... Collect the ISA firewall client configuration information ...
      (microsoft.public.windows.server.sbs)
    • Re: PHP & MySQ + unique keys
      ... :>> I'm trying to write a system thats used for about 50 clients that uses ... The problem is that when a client ... :>> when you refresh the page that the unique key is incremented as you ... session is using. ...
      (comp.lang.php)
    • Re: Database design
      ... Is each session related to a client? ... Yes, each session is related to a single client, or so I anticipate. ... (fsubSession and fsubProduct) ...
      (microsoft.public.access.tablesdbdesign)
    • Re: RDP Printing by station
      ... For example, port 3389 would have print redirection enabled, whereas port 3390 would have print redirection disabled. ... I am not sure this is a possible solution anymore, because you said that there would be printing to not only redirected printers but network printers as well. ... In this case, the user could originally connect from an ip that is permitted, disconnect their session, and reconnect from an ip that is not permitted. ... Your client software would use this channel to send the local MAC address to your server software. ...
      (microsoft.public.windows.terminal_services)

  • Quantcast