alex_bn_lee

导航

【205】C#实现远程桌面访问

参考:Remote Desktop using C#.NET

参考文件:TscForm.zip

        本博客主要是讲述怎样用 .NET 平台中 Microsoft Terminal Services Client ActiveX control 来实现远程桌面的访问。

做法:

1. 在 Visual Studio 中添加引用,添加 COM 中的 “Microsoft Terminal Services Control Type Library”,这个过程将会把 MSTSCLib.dll 添加到项目中。

2. 在工具栏中添加控件,在工具栏上右键选择“选择项...”,将 COM 组件中的 “Microsoft Terminal Services Client Control” 选中,确定后就会有相应的控件出现,然后拖拽就可以使用了。

3. 实现代码:axMsTscAxNotSafeForScripting1 为控件的名称,str_computer 为 IP 地址、str_userName 为用户名、str_password 为密码。

    axMsTscAxNotSafeForScripting1.Server = str_computer;
    axMsTscAxNotSafeForScripting1.UserName = str_userName;
    IMsTscNonScriptable secured = (IMsTscNonScriptable)axMsTscAxNotSafeForScripting1.GetOcx();
    secured.ClearTextPassword = str_password;
    axMsTscAxNotSafeForScripting1.Connect();

 

posted on 2016-05-16 11:27  McDelfino  阅读(13933)  评论(1编辑  收藏  举报