Windows Remote Desktop Client

Source: Internet
Author: User
Tags windows remote desktop

1, register the control: regsvr32 C:\Windows\System32\mstscax.dll.

2. Add the RDP control control to the toolbox. My choice of RDP Client Control (Redistributable)-Version 9

3. Quoting C:\Windows\System32\mstscax.dll in VS project

4, Rdptabpage class

usingSystem;usingSystem.Windows.Forms;namespacerdpclient{ Public classrdptabpage:tabpage {axmstsclib.axmsrdpclient9 rdpc=NULL; protected Override voidOncreatecontrol () {RDPC=Newaxmstsclib.axmsrdpclient9 (); RDPC. Ondisconnected+=NewAxmstsclib.imstscaxevents_ondisconnectedeventhandler (rdpc_ondisconnected);  This.            Controls.Add (RDPC); RDPC. Dock=DockStyle.Fill; Base.        Oncreatecontrol (); }        voidRdpc_ondisconnected (Objectsender, Axmstsclib.imstscaxevents_ondisconnectedevent e) {(TabControl) This. Parent). Tabpages.remove ( This); }         Public voidDisconnect () {Try            {                if(RDPC. Connected = =1) {rdpc.                Disconnect (); }            }            Catch(Exception) {}}Private voidsetrdpclientproperties (rdpinfo info) {rdpc. Server=info.            MachineName; RDPC. UserName=info.            UserName; RDPC. Domain=""; RDPC. Advancedsettings9.rdpport=info.            Rdpport; RDPC. Advancedsettings9.cleartextpassword=info.            Password; RDPC. Advancedsettings9.redirectdrives=true; RDPC. Advancedsettings9.redirectprinters=true; RDPC. Advancedsettings9.redirectsmartcards=true; RDPC. Advancedsettings9.connecttoserverconsole=true; RDPC. ColorDepth= +; RDPC. Dock=DockStyle.Fill; }         Public voidConnect (rdpinfo info) {setrdpclientproperties (info); RDPC.        Connect (); }    }}

5. Main form

usingSystem;usingSystem.Windows.Forms;namespacerdpclient{ Public Partial classForm_main:form {#regionStructure PublicForm_main () {InitializeComponent (); }        #endregion        #regionMethod/// <summary>        ///binding Remote Desktop list/// </summary>        Private voidBindmenuitem () {tsb_Rdps.DropDownItems.Clear (); if(Config.rdpinfos = =NULL)return; foreach(varInfoinchConfig.RdpInfos.Items) {ToolStripMenuItem Item=NewToolStripMenuItem (); Item. Imagescaling=Toolstripitemimagescaling.sizetofit; Item. Name=string. Format ("menuitem{0}", Info.                AliasName); Item. Text=info.                aliasname; Item. Tag=info;            TSB_RDPS.DROPDOWNITEMS.ADD (item); }        }         Public voidrdpconnect (rdpinfo info) {rdptabpage Rdptab=NewRdptabpage (); Rdptab.text=info.            aliasname; foreach(TabPage TPinchtab_rdps.tabpages) {                if(TP.) Text = =rdptab.text) {tab_rdps.selecttab (TP); return;            }} tab_Rdps.TabPages.Add (Rdptab);            Rdptab.connect (info);        Tab_rdps.selecttab (Rdptab); }        #endregion        #regionEventPrivate voidForm_main_load (Objectsender, EventArgs e) {rdpclient.visible=false;            Config.load ();        Bindmenuitem (); }        Private voidForm_main_formclosing (Objectsender, FormClosingEventArgs e) {            if(MessageBox.Show ("OK exit program? ","Tips", Messageboxbuttons.okcancel, messageboxicon.question) = =dialogresult.cancel) {e.cancel=true; return; }        }        /// <summary>        ///Connect to Remote Desktop/// </summary>        Private voidTsb_rdps_dropdownitemclicked (Objectsender, ToolStripItemClickedEventArgs e) {Rdpinfo Item= E.clickeditem.tag asRdpinfo; if(Item = =NULL)return;        Rdpconnect (item); }        /// <summary>        ///close the Remote desktop of the current tab page/// </summary>        Private voidTsb_disconnect_click (Objectsender, EventArgs e) {            if(Tab_rdps.selectedindex <0)return; Rdptabpage Rdptab=(rdptabpage) Tab_rdps.selectedtab; if(Rdptab! =NULL) {rdptab.disconnect (); }        }        /// <summary>        ///Close all tab pages for Remote Desktop/// </summary>        Private voidTsb_disconnectall_click (Objectsender, EventArgs e) {            foreach(TabPage tabinchtab_rdps.tabpages) {Rdptabpage Rdptab=(rdptabpage) tab;            Rdptab.disconnect (); }        }        /// <summary>        ///maximized/// </summary>        Private voidTsb_max_click (Objectsender, EventArgs e) {            if(Tab_rdps.selectedindex <0)return; Rdptabpage Rdptab=(rdptabpage) Tab_rdps.selectedtab; if(Rdptab! =NULL)            {                varRDPC = rdptab.controls[0] asaxmstsclib.axmsrdpclient9; RDPC. Fullscreen=true; RDPC. Fullscreentitle=Rdptab.text; }        }        Private voidTsb_config_click (Objectsender, EventArgs e) {form_settings Form=Newform_settings (); if(Form. ShowDialog () = =DialogResult.OK) {Bindmenuitem (); }        }        Private voidTsb_about_click (Objectsender, EventArgs e) {MessageBox.Show ("Remote Desktop","Information", MessageBoxButtons.OK, messageboxicon.information);        }        #endregion    }}

6, the program download site directly

Https://pan.baidu.com/s/1Fcolic2QAcNANJszscVUjg

Windows Remote Desktop Client

Related Article

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.