首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Winform中托管RemoteAPP会话

在Winform中托管RemoteAPP会话
EN

Stack Overflow用户
提问于 2013-05-30 21:39:07
回答 1查看 5.7K关注 0票数 13

不断地回到这个问题上来,却找不到答案。我正在创建一个工作的应用程序,基本上编译成一个更容易使用的GUI我们所有的工具。我们使用的工具之一是我们从第三方使用的东西,并通过RDWeb作为远程应用程序托管。现在我也有了常规的远程桌面访问,我可以使用MSTSC和this process通过我的Winform访问桌面,它工作得很漂亮。我很好奇是否有可能只加载RemoteAPP,而不是MSTSC控件中的整个桌面,这样我的用户就不会访问完整的桌面。或者是否有任何其他方式只在Winforms中托管RemoteAPP。

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

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

代码语言:javascript
复制
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);
}

也许我在这方面走错了路,或者这甚至不可能。我只想在正确的方向上推动,我不需要任何人为我写这篇文章。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-06-17 02:02:19

IMsRdpClient.RemoteProgram.RemoteProgramMode仅在从MsRdpClientNotSafeForScripting类ids初始化的客户端上有效。有关适当的CLSID,请参见this MSDN page,或使用AxMsRdpClientNotSafeForScripting互操作类。

代码语言:javascript
复制
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();
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16837808

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档