简体   繁体   中英

Mstsc ActiveX Control Warning

I'm working in a project that the application needs to connect into a remove desktop (RDP Protocol), automatically. For this, I'm using the library MSTSCLib_TLB, from Delphi, which uses mstscax.dll. The problem is that the Windows identifies the connection is coming from an ActiveX control, and display this warning:

在此处输入图片说明

This warning is making difficult to connect automatically on the server.

Note: "A website is trying to start a remote connection", while I'm doing this from an executable... I read on the Internet about this message, and tried some solutions on Windows registry, but none of them solved the problem. I accept solutions that work on the Windows registry to stop displaying this warning, but I prefer programmatically solutions . I saw a sugestion to sign the ActiveX object using IObjectSafety and set SetInterfaceSafetyOptions to "INTERFACESAFE_FOR_UNTRUSTED_CALLER", but I have no idea about what this means and how to achieve that.

My application is coded on Delphi, and I'm on Windows 10. The code so far is:

procedure TForm1.Button1Click(Sender: TObject);
var
  Client: TMsRdpClient9;
begin
  Client:= TMsRdpClient9.Create(Self);
  Client.Parent:= Self; //dont know why, but this ActiveX control needs a parent
  Client.Server:= Edit1.Text;
  Client.UserName:= Edit2.Text;
  Client.AdvancedSettings9.ClearTextPassword:= Edit3.Text;
  Client.OnLoginComplete:= LoginComplete;
  Client.Connect;
end;

Got it. Instead of using "TMsRdpClient9" I used "TMsRdpClientNotSafeForScripting" with the following code:

procedure TForm1.Button1Click(Sender: TObject);
var
  Client: TMsRdpClientNotSafeForScripting;
begin
  Client:= TMsRdpClientNotSafeForScripting.Create(Self);
  Client.Parent:= Form1;
  Client.Server:= Edit1.Text;
  Client.ControlInterface.UserName:= Edit2.Text;
  Client.AdvancedSettings2.ClearTextPassword:= Edit3.Text;
  Client.Connect;
end;

The essence of the answer provided by user3810691 works also for C# WinForms. In the COM Components tab (for Choose Toolbox Items) go for:

Microsoft RDP Client Control - version 10

instead of:

Microsoft RDP Client Control (redistributable) - version 10

This will give you the "not safe for scripting" version 9 (sic!) control type:

AxMSTSCLib.AxMsRdpClient9NotSafeForScripting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM