Hosting RemoteAPP session within Winform

淺唱寂寞╮ 提交于 2019-12-02 22:16:19

IMsRdpClient.RemoteProgram.RemoteProgramMode is only valid on clients initialized from the MsRdpClientNotSafeForScripting class ids. See this MSDN page for the appropriate CLSIDs, or use the AxMsRdpClientNotSafeForScripting interop class.

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();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!