C# AxMsRdpClient9取消登录对话框

C# AxMsRdpClient9取消登录对话框,c#,.net,rdp,mstsc,C#,.net,Rdp,Mstsc,我正在使用c#编写rdp客户端。简单的例子: AxMsRdpClient9NotSafeForScripting c = new AxMsRdpClient9NotSafeForScripting(); Form1.Controls.Add(c); c.Server = s.ip; c.UserName = s.pass; c.AdvancedSettings9.ClearTextPassword = s.pass;

我正在使用c#编写rdp客户端。简单的例子:

        AxMsRdpClient9NotSafeForScripting c = new AxMsRdpClient9NotSafeForScripting();
        Form1.Controls.Add(c);
        c.Server = s.ip;
        c.UserName = s.pass;
        c.AdvancedSettings9.ClearTextPassword = s.pass;
        c.Connect();
因此,当我尝试连接到Win7或更低版本时,它工作得非常完美,但当我尝试连接到Win Server 2012时,rdpclient不连接,也不返回任何错误。使用此选项时,连接到win server会起作用:

c.AdvancedSettings9.EnableCredSspSupport = true;
但有了这个选项,当我试图用无效凭证连接到win服务器时,它会显示一个带有login\pass字段的对话框,我不能以编程方式取消它,我必须“手动”完成。 所以问题是:我怎样才能连接到win服务器而不必安装服务器

c.AdvancedSettings9.EnableCredSspSupport = true;

或者如何在代码中取消登录\传递对话框?

解决方案是将AllowPromptingForCredentials设置为false。

以下是完成@davyjohnes answer的其他详细信息:

....
Form1.Controls.Add(c);
var ocx = c.GetOcx() as MSTSCLib.IMsRdpClientNonScriptable5;
ocx.AllowPromptingForCredentials = false;
c.Server = s.ip;
....

谢谢我会发布我花了一点时间才弄明白的额外细节,以防其他人被这件事绊倒。