Windows Terminal Services and C#


  • Hello.

    Could there be a way to have a Windows App that can display the current users and the ability to send message to a selected user?

    The scenario goes this way. I have my local computer connected to a remote computer elsewhere through Remote Desktop connection. There are many users connected on the same computer server aside from me. With the help of Task Manager, we can send messages to each other, however, it has only an OK button.

    I just want to have the same concept, with a Reply Button and with my own design.

    I hope you get what I meant.

    Thank you,
    Friday, June 27, 2008 7:51 AM


All replies

  • There is no such capability in C# or .the Net class library. You need to call Windows Terminal Service API directly.
    MSMVP VC++
    Friday, June 27, 2008 7:04 PM
  • Sheng Jiang 蒋晟 said:

    There is no such capability in C# or .the Net class library. You need to call Windows Terminal Service API directly.

    MSMVP VC++

    A good news if there is a possiblity, but how can I do that? Do you have any samples or some kind??

    I'm new in programming, and I have no idea yet with calling Windows API directly. Please help

    Sunday, June 29, 2008 11:09 PM
  • To call Terminal Service API you need to use Platform Invoke
    For questions regarding terminal service, you can ask in the Terminal Services forum or the terminal service team blog.

    MSMVP VC++
    • Marked as answer by jack 321 Wednesday, July 02, 2008 2:14 AM
    Monday, June 30, 2008 6:35 PM
  • Engel,

    You can do this with the Cassia library, which uses the Terminal Services API internally. For example, the following program asks each active user on the given server whether it is OK to shut down and displays the users' responses:
    using System;
    using Cassia;
    namespace CassiaSample
        public static class Program
            public static void Main(string[] args)
                ITerminalServicesManager manager = new TerminalServicesManager();
                using (ITerminalServer server = manager.GetRemoteServer("your-server-name"))
                    foreach (ITerminalServicesSession session in server.GetSessions())
                        string userName = session.UserName;
                        if (session.ConnectionState != ConnectionState.Active || userName == null)
                        RemoteMessageBoxResult response =
                            session.MessageBox("Is it OK to shut down now?", "Shutdown", RemoteMessageBoxButtons.YesNo,
                                               RemoteMessageBoxIcon.Question, RemoteMessageBoxDefaultButton.Button1,
                                               RemoteMessageBoxOptions.None, TimeSpan.Zero, true);
                        Console.WriteLine(userName + " says " + response);
    Wednesday, May 13, 2009 2:11 AM