13

これに戻ってきて、それを理解することができません...私は、すべてのツールを本質的に使いやすいGUIにコンパイルする仕事用のアプリを作成しています。私たちが使用するツールの 1 つはサード パーティ製のもので、RDWeb 経由でリモート アプリとしてホストされています。これで、通常のリモート デスクトップ アクセスも可能になり、MSTSC を使用して Winform 経由でデスクトップにアクセスでき、このプロセスは美しく機能します。ユーザーが完全なデスクトップに到達しないように、MSTSC コントロールのデスクトップ全体ではなく、RemoteAPP のみをロードできるかどうか、興味があります。または、Winforms 内で RemoteAPP Only をホストする他の方法がある場合。

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

おそらく、私はこれを間違った方法で行っているか、おそらく不可能です。誰かにこれを書いてもらう必要はありません。

4

1 に答える 1

4

IMsRdpClient.RemoteProgram.RemoteProgramModeMsRdpClientNotSafeForScriptingクラス IDから初期化されたクライアントでのみ有効です。適切な CLSID については、この MSDN ページを参照するか、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();
于 2013-06-16T18:02:18.710 に答える