欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

利用微软com组件mstscax.dll实现window7远程桌面功能

程序员文章站 2024-02-18 22:57:58
复制代码 代码如下:namespace client{    public partial class login : form &...

复制代码 代码如下:

namespace client
{
    public partial class login : form
    {
        private string ip = null;

        public login()
        {
            initializecomponent();
        }

        public login(string ip)
        {
            initializecomponent();
            ip = ip;
        }

        private void login_load(object sender, eventargs e)
        {
            this.formclosing += login_closing;

            this.text = string.format("登录到:{0}", ip);
            // 获取主机显示器屏幕分辨率
            rectangle rect = screen.primaryscreen.bounds;
            try
            {
                rdp.server = ip;
                rdp.advancedsettings2.rdpport = 3389;
                rdp.height = rect.height;
                rdp.width = rect.width;
                //rdp.username = "client";
                //rdp.advancedsettings2.cleartextpassword = "client";
                rdp.connect();
                rdp.fullscreen = true;
                //this.formborderstyle = formborderstyle.none;
                rdp.fullscreentitle = this.text;
            }
            catch (system.exception ex)
            {
                messagebox.show(ex.message);
            }
        }

        private void login_closing(object sender, formclosingeventargs e)
        {
            if (messagebox.show("确认退出么?", "提示", messageboxbuttons.yesno,
                messageboxicon.question, messageboxdefaultbutton.button2) == dialogresult.no)
                e.cancel = true;
        }
    }
}