Nab*_*bic 12 c# rdp remoteapp winforms
继续回到这个并且无法理解......我正在创建一个工作应用程序,它基本上将我们所有的工具编译成一个更易于使用的GUI.我们使用的工具之一是我们从第三方使用的工具,并通过RDWeb作为远程应用程序托管.现在我也经常进行远程桌面访问,我可以使用MSTSC通过我的Winform访问桌面,这个过程非常有效.我很好奇是否可以在MSTSC控件中加载RemoteAPP而不是整个桌面,这样我的用户就无法访问完整的桌面.或者,如果在Winforms中有任何其他方式来托管RemoteAPP.
我已经查看了ITSRemoteProgram上的MSDN文档,但是当我尝试以下操作时,它只会抛出异常.调试器停止rdp.RemoteProgram.RemoteProgramMode = true;并给出HRESULT E_FAIL异常.
我也试过使用remoteprogramOnConnected事件后触发,我得到相同的结果.
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);
}
Run Code Online (Sandbox Code Playgroud)
也许我会以错误的方式走这条路,或者甚至不可能.我想在正确的方向上轻推我不需要任何人为我写这个.
IMsRdpClient.RemoteProgram.RemoteProgramMode仅对从类 ID 初始化的客户端有效MsRdpClientNotSafeForScripting。请参阅此 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();
Run Code Online (Sandbox Code Playgroud)