参考: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 添加到项目中。

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

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

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

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

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

 

相关文章:

  • 2022-01-22
  • 2021-07-19
  • 2021-08-03
  • 2021-07-25
  • 2021-10-30
  • 2021-05-27
  • 2021-05-11
  • 2022-12-23
猜你喜欢
  • 2021-05-16
  • 2022-12-23
  • 2021-12-25
  • 2021-11-19
  • 2021-05-28
  • 2022-02-08
  • 2021-12-31
相关资源
相似解决方案