From: Tim Mangan on
If your code is running as a service, your code in running in session 0, no
matter what session the user is loggin in under.
--
Tim Mangan [MVP]
TMurgent Technologies


"v.mont" wrote:

> Thanks Thomas,
>
> I need to write the server side as a service, so it needs to monitor when
> connections get established. Either that, or I need a way to get the server
> side launched as soon as a connection is established, but before the user
> logs in. If I run as a service, I can't write to WTS_CURRENT_SESSION.
>
> Also in my test program, WTS_CURRENT_SESSION (-1) and session 2 are same
> session. However if I specify session 2 instead of WTS_CURRENT_SESSION in the
> method call, the write fails.
>
>
> "ThomasT." wrote:
>
> > Hi,
> > For your 1st question, you can do a virtual driver on the client side to
> > response a ping from server,
> > I have always used this method and it works very well.
> >
> > #2- I never try to open VC on a different user's session, it seems not a
> > good pratice, because the permission issue,
> > I always use VC between client and server in the same session, it works very
> > very well, very stable and fast.
> >
> >
> > ========================
> > Thomas T.
> > http://www.mqtechnologies.com
> > ========================
> >
> > "v.mont" <vmont(a)discussions.microsoft.com> wrote in message
> > news:2F0DC68E-2BEB-4E57-B3BE-937DC4AFE2B3(a)microsoft.com...
> > > Okay, I figured out my issue on #2 below, but not sure what the solution
> > > is.
> > > The problem is that when I connect, the session id is (for example) '2'.
> > > if
> > > I do:
> > >
> > > ::WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, 2, "mychannel")
> > >
> > > I get the "invalid function" error when I try to write (and yes, the
> > > session
> > > id seems to be correct)
> > >
> > > However if I do:
> > >
> > > ::WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION.,
> > > "mychannel")
> > >
> > > things work okay.
> > >
> > > Maybe it has to do with this statement:
> > >
> > > "To be able to open a virtual channel on another user's session, you need
> > > to
> > > have the Virtual Channels permission. For more information, see Terminal
> > > Services Permissions. To modify permissions on a session, use the Terminal
> > > Services Configuration administrative tool."
> > >
> > > ...but this is XP so there is no admin tool (so how do I test this?), nor
> > > am
> > > i trying to open a different user's session. So this is still confusing
> > > me.
> > > Eventually I will convert this to run as a service, so help would still be
> > > appreciated.
> > >
> > > "v.mont" wrote:
> > >
> > >> Hi,
> > >>
> > >> Two quick questions about implementing a virtual channel:
> > >>
> > >> 1. How can you tell from the server side if the client virtual channel
> > >> endpoint is implemented? From my testing, it seems that
> > >> WTSVirtualChannelOpen
> > >> succeeds regardless if I load the client dll or not. Is this correct
> > >> behaviour? Do I need to implement a handshake?
> > >>
> > >> 2. In my implementation on the server side, i can read from the channel
> > >> but
> > >> I cannot write to it, either using WTSVirtualChannelWrite or the file
> > >> handle.
> > >> It always returns error code 1 (incorrect function). Reading from the
> > >> same
> > >> handle works fine. Am i doing something wrong?
> > >>
> > >> By the way, my client is vista, my server is XP.
> > >>
> > >> Any hints would be appreciated.
> > >>
> >
> >
> >