【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();

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM