简体   繁体   中英

Remote Desktop Connection with MSTSCLib

I'm trying to code a Remote Desktop Application using C# .NET.

I followed some examples (listed below) and created a Windows Form, added references to MSTSLib, added Microsoft Terminal Service Control to the Form and code the following behavior:

namespace RDConnector
{
    public partial class Form1 : Form
    {    
        const string server = "55.55.55.555";
        const string userNameBase = "username";
        const string passwordBase = "password";

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                rdClient.Server = server;
                rdClient.UserName = userNameBase;    

                /*IMsTscNonScriptable secured = (IMsTscNonScriptable)rdClient.GetOcx();
                secured.ClearTextPassword = passwordBase;*/

                rdClient.AdvancedSettings8.DisplayConnectionBar = true;
                rdClient.AdvancedSettings8.ClearTextPassword = passwordBase;
                rdClient.AdvancedSettings8.EncryptionEnabled = -1;                 

                //// Start connection
                rdClient.Connect();
                MessageBox.Show("Connection Status + " + rdClient.Connected.ToString());

            }
            catch (Exception Ex)
            {
                MessageBox.Show("Exception ocurred: " + Ex.Message);
            }
        }
    }
}

However, it isn't working, the Connection status after calling rdClient.Connect() is 2 (0 before calling it), but nothing happens. I also ran the Example 1 and it doesn't work.

I'm using Windows 7 - 64 bit and Visual Studio C# Express. Visual Express Edition doesn't have a X64 compiler, Could be the problem related with that?

I'll really appreciate your help.

Examples:

  1. http://www.codeproject.com/KB/cs/RemoteDesktop_CSharpNET.aspx

  2. Running COM component controls on multiple threads

I found the problem at last. When you want to choose COM Components, just select "Microsoft RDP Client Control - version x". I choose the 8 version that works perfectly for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM