在Winform中托管RemoteAPP会话

继续回到这个并且无法理解……我正在创建一个工作应用程序,它基本上将我们所有的工具编译成一个更易于使用的GUI。 我们使用的工具之一是我们从第三方使用的工具,并通过RDWeb作为远程应用程序托管。 现在我也经常使用远程桌面访问,我可以使用MSTSC通过Winform访问桌面, 这个过程非常有效。 我很好奇是否可以加载RemoteAPP而不是MSTSC控件中的整个桌面,这样我的用户就无法进入完整的桌面。 或者,如果在Winforms中有任何其他方式来托管RemoteAPP。

我已经查看了ITSRemoteProgram上的MSDN文档,但是当我尝试以下操作时它只会引发exception。调试器在rdp.RemoteProgram.RemoteProgramMode = true;处停止rdp.RemoteProgram.RemoteProgramMode = true; 并给出一个HRESULT E_FAILexception。

我也尝试在OnConnected事件触发后使用remoteprogram ,我得到相同的结果。

 try { rdp.Server = "FFWIN2008R2DC.fflab123.net"; rdp.Domain = "fflab123"; rdp.UserName = "administrator"; IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx(); secured.ClearTextPassword = "password123"; rdp.OnConnected += rdp_OnConnected; rdp.RemoteProgram.RemoteProgramMode = true; rdp.RemoteProgram2.RemoteApplicationName = "Calculator"; rdp.RemoteProgram2.RemoteApplicationProgram = @"C:\Windows\system32\calc.exe"; rdp.Connect(); } catch (Exception Ex) { MessageBox.Show("Error Connecting", "Error connecting to remote desktop " + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } 

也许我会以错误的方式走这条路,或者甚至不可能。 我只想在正确的方向上轻推我不需要任何人为我写这个。

IMsRdpClient.RemoteProgram.RemoteProgramMode仅在从MsRdpClientNotSafeForScripting类ID初始化的客户端上有效。 请参阅此MSDN页面以获取相应的CLSID,或使用AxMsRdpClientNotSafeForScripting互操作类。

 var rc = new AxMsRdpClient7NotSafeForScripting(); rc.Dock = DockStyle.Fill; this.Controls.Add(rc); rc.RemoteProgram.RemoteProgramMode = true; // ServerStartProgram can only be called on an open session; wait for connected until calling rc.OnConnected += (_1, _2) => { rc.RemoteProgram.ServerStartProgram(@"%SYSTEMROOT%\notepad.exe", "", "%SYSTEMROOT%", true, "", false); }; rc.Server = "server.name"; rc.UserName = "domain\\user"; // needed to allow password rc.AdvancedSettings7.PublicMode = false; rc.AdvancedSettings7.ClearTextPassword = "password"; // needed to allow dimensions other than the size of the control rc.DesktopWidth = SystemInformation.VirtualScreen.Width; rc.DesktopHeight = SystemInformation.VirtualScreen.Height; rc.AdvancedSettings7.SmartSizing = true; rc.Connect();