gpt4 book ai didi

Delphi/Rdp 在连接前检查用户名和密码

转载 作者:行者123 更新时间:2023-12-01 23:35:11 27 4
gpt4 key购买 nike

正如主题所说,我尝试在delphi中使用此代码连接到服务器

procedure TmainF.Button1Click(Sender: TObject);
var
rdp1 : TMsRdpClient7NotSafeForScripting ;
begin
rdp1 := TMsRdpClient7NotSafeForScripting.Create(self);
rdp1.Parent := mainF;
rdp1.Server:=server_name;
rdp1.UserName := user.Text;
rdp1.AdvancedSettings7.ClearTextPassword := password.Text;
rdp1.ConnectingText := 'connecting';
rdp1.DisconnectedText := 'disconnected';
rdp1.AdvancedSettings7.AuthenticationLevel:=0;
rdp1.AdvancedSettings7.EnableCredSspSupport:=true;
rdp1.Connect;
end;

代码工作正常,但如果用户输入了错误的用户名或密码
rdp对象显示远程桌面登录提示框,需要重新输入用户名或密码,如图

enter image description here

我想在连接之前验证用户名和密码
或阻止此框并显示来 self 的应用程序的自定义消息

我尝试使用 OnLogonError() 过程,但它没有触发任何代码
我读了这个Question但代码是 c#,我对 .getocx() 感到困惑,并且在 (MSTSCLib_TLB.pas) 中找不到 (PromptForCredentials)

任何帮助:(??

抱歉我的英语不好。

最佳答案

有一个接口(interface)IMsRdpClientNonScriptable5,它具有以下方法:

  • Get_AllowPromptingForCredentials()
  • Set_AllowPromptingForCredentials()

如果您调用 Set_AllowPromptingForCredentials() 并将参数设置为 false,则不会出现该对话框。

至于如何获取此接口(interface)的实例 - 很简单,您只需转换 RDP 客户端对象的 ControlInterface 即可:

Ircns5 := rdp1.ControlInterface as IMsRdpClientNonScriptable5;
if Assigned(Ircns5) then
Ircns5.Set_AllowPromptingForCredentials(False);

关于Delphi/Rdp 在连接前检查用户名和密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47515147/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com