user3810691
user3810691

Reputation: 531

Delphi ActiveX MSTSCLib

I'm trying to play around with some Delphi ActiveX library for MS-RDP (mstscax.dll), so I imported the library into my project, and started looking for some codes snippets on the web. On a first look, it's pretty obvious, but the lack of examples makes it a little complex.

First the library gives an error on Delphi Seattle, on this line:

property ConnectWithEndpoint: POleVariant1 write Set_ConnectWithEndpoint;

Ok, I commented this line out (not the best solution, I know), but it compiled. Later I tried to change POleVariant1 to OleVariant only, and still compiling. Ok, after compiled, I tried this code:

var
  Form1: TForm1;
  RDP: TMsRdpClient8NotSafeForScripting;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  RDP:= TMsRdpClient8NotSafeForScripting.Create(Nil);
  RDP.Server:= 'xxxx';
  RDP.AdvancedSettings8.RDPPort:= 3389;
  RDP.UserName:= 'terminal';
  RDP.AdvancedSettings8.ClearTextPassword:= '123456';
  RDP.Connect;
  if RDP.Connected.ToBoolean = true then
    ShowMessage('connected')
  else
    ShowMessage('error');

end;

I tried some different types for the var RDP, like TMsRdpClient8 only, but still the same problem: It don't even try to connect! While looking on the sniffer, no tcp connections are made, just nothing happens and the "error" message appears. Any idea about how to work with this guy?

Upvotes: 0

Views: 2108

Answers (1)

Allen Bauer
Allen Bauer

Reputation: 16842

This question intrigued me so I tried to import that ActiveX control and try it myself. It seems to work for me, so I'll explain what I did.

I imported the mstscax.dll ActiveX control then added it to a new package in order to install components onto the tool palette. I immediately ran into the error you did with the ConnectWithEndpoint property. I changed the type in the declaration to OleVariant because the Set_ConnectWithEnpoint property setter function takes an OleVariant. There is clearly something about the type information that our ActiveX importer code is getting confused by. Either way, that change got the file to compile and install the component package. There are now a bunch of TMsRdpClientXXXX components.

Created a new VCL Forms project, then dropped the TMsRdpClient9 component into the form. Added a TButton and then added this code into the button's OnClick handler:

  MsRdpClient91.Server := '<some remote server>';
  MsRdpClient91.Domain := 'embarcadero.com';
  MsRdpClient91.UserName := 'abauer';
  MsRdpClient91.Connect;

Once I ran the app, and pressed the button, it connected and the content of the ActiveX control showed the remote server login screen just fine.

I'm running Windows 10, build 10565.

Here's what I'm seeing on my little app I wrote: enter image description here

Upvotes: 2

Related Questions