C # use multiple Remote Desktop connections

Source: Internet
Author: User
Tags mstsc
Preface: if you are using a Windows Server server, you can find the function of connecting to multiple remote desktops, but you cannot use the XP operating system. The Remote Desktop function uses the mstsc file. In the System32 folder, you can find the mstscax. dll dynamic Connection Library, which is the main component for achieving remote connection. Download a Remote Desktop function written in C # that can connect to multiple Windows servers.

Source code
Http://www.codeproject.com/KB/cs/RemoteDesktopClient.aspx
You can go to the above URL to learn more details.


The left side is a remote list, and the right side is the MDI display area. Multiple Remote interfaces can be displayed.
 
It is a description of this tool, developed using vs2008 RTM, And the. NET version is 3.5sp1.
 

Source code analysis
I believe that the most interesting part of this program is the code connecting to the mstsc dynamic link library.
The rdpclient is an object of the axmstsclib. axmsrdpclient type.
The statement is as follows:
Public axmstsclib. axmsrdpclient rdpclient;
Remote connection

Public void connect () // www.elivn.com
{
Status ("starting ...");
Rdpclient. Connect ();
}

Disconnect a remote connection

Public void disconnect ()
{
Status ("disconnecting ...");
Rdpclient. disconnectedtext = "disconnected ";

If (rdpclient. connected! = 0)
{
Rdpclient. Disconnect ();
}
}

Reconnect to a remote object
During the connection, you must specify the server, user name, and password.

Public void reconnect (bool haschanges, bool isfittowindow)
{
Disconnect ();

Status ("waiting for the server to properly disconnect ...");

// Wait for the server to properly disconnect
While (rdpclient. connected! = 0)
{
System. Threading. thread. Sleep (1000 );
Application. doevents ();
}

Status ("reconnecting ...");

If (haschanges)
{
Rdpclient. Server = This. _ ss. server;
Rdpclient. Username = This. _ ss. Username;
Rdpclient. advancedsettings2.cleartextpassword = This. _ ss. Password;
Rdpclient. colordepth = This. _ ss. colordepth;

This. _ isfittowindow = isfittowindow;

If (isfittowindow)
{
Rdpclient. Required topwidth = This. rdpclient. width;
Rdpclient. Required topheight = This. rdpclient. height;
}
Else
{
Rdpclient. Required topwidth = This. _ ss. Required topwidth;
Rdpclient. Required topheight = This. _ ss. Required topheight;
}

Rdpclient. fullscreen = This. _ ss. fullscreen;
}

Connect ();
}

A large number of COM interface functions are used during the connection process.
This program can be used as an important reference for. Net to implement remote desktop.

Preface: if you are using a Windows Server server, you can find the function of connecting to multiple remote desktops, but you cannot use the XP operating system. The Remote Desktop function uses the mstsc file. In the System32 folder, you can find the mstscax. dll dynamic Connection Library, which is the main component for achieving remote connection. Download a Remote Desktop function written in C # that can connect to multiple Windows servers.

Source code
Http://www.codeproject.com/KB/cs/RemoteDesktopClient.aspx
You can go to the above URL to learn more details.


The left side is a remote list, and the right side is the MDI display area. Multiple Remote interfaces can be displayed.
 
It is a description of this tool, developed using vs2008 RTM, And the. NET version is 3.5sp1.
 

Source code analysis
I believe that the most interesting part of this program is the code connecting to the mstsc dynamic link library.
The rdpclient is an object of the axmstsclib. axmsrdpclient type.
The statement is as follows:
Public axmstsclib. axmsrdpclient rdpclient;
Remote connection

Public void connect () // www.elivn.com
{
Status ("starting ...");
Rdpclient. Connect ();
}

Disconnect a remote connection

Public void disconnect ()
{
Status ("disconnecting ...");
Rdpclient. disconnectedtext = "disconnected ";

If (rdpclient. connected! = 0)
{
Rdpclient. Disconnect ();
}
}

Reconnect to a remote object
During the connection, you must specify the server, user name, and password.

Public void reconnect (bool haschanges, bool isfittowindow)
{
Disconnect ();

Status ("waiting for the server to properly disconnect ...");

// Wait for the server to properly disconnect
While (rdpclient. connected! = 0)
{
System. Threading. thread. Sleep (1000 );
Application. doevents ();
}

Status ("reconnecting ...");

If (haschanges)
{
Rdpclient. Server = This. _ ss. server;
Rdpclient. Username = This. _ ss. Username;
Rdpclient. advancedsettings2.cleartextpassword = This. _ ss. Password;
Rdpclient. colordepth = This. _ ss. colordepth;

This. _ isfittowindow = isfittowindow;

If (isfittowindow)
{
Rdpclient. Required topwidth = This. rdpclient. width;
Rdpclient. Required topheight = This. rdpclient. height;
}
Else
{
Rdpclient. Required topwidth = This. _ ss. Required topwidth;
Rdpclient. Required topheight = This. _ ss. Required topheight;
}

Rdpclient. fullscreen = This. _ ss. fullscreen;
}

Connect ();
}

A large number of COM interface functions are used during the connection process.
This program can be used as an important reference for. Net to implement remote desktop.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.