在 Delphi 中设置 COM (RDPEncomAPI) 属性

Setting COM (RDPEncomAPI) property in Delphi

我已经使用 Delphi 一段时间了,但我正在尝试一些 COM 编程,但遇到了麻烦。如果这是一个 NewBie 问题,我深表歉意,但在尝试了很多东西后,我无法获取或设置 RDPEncom RDPSession 对象的属性。代码(包括几个天真的尝试)如下。如果我删除试图读取属性的行,其余代码可以正常工作。

如何获取和设置 RDPSession.Properties 的端口 ID 属性?

uses rdpencomapi_TLB;  // from JWAPI

...

myRDPSession := CoRDPSession.Create();
if VarIsNull(myRDPSession) then
begin
  application.MessageBox('MsRdpSession creation failed.', 'Error');
  Result := False;
  Exit;
end;
try
  didShare := myRDPSession.Open;
except
  ShowMessage('Unable to share desktop !');
  Exit;
end;
theProperty := 'PortID';
ActiveXProp := myRDPSession.Properties;
//lValues := ActiveXProp.Property_(theProperty); // method not supported
//lValues := ActiveXProp.Property(theProperty); // member not found
myRDPSession.Properties.GetProperty(lValues, myRDPSession.Properties.Property, theProperty);
{
 ALL RETURN INVALID NUMBER OF PARAMETERS..
    ActiveXProp.GetProperty(lValues, ActiveXProp.Property, 'PortID');
    ActiveXProp.Property.GetProperty(ActiveXProp.Property, lValues, 'PortID');
    ActiveXProp.Property.GetProperty(lValues, ActiveXProp, 'PortID');
    ActiveXProp.Property.Get_Prop_('PortID', ActiveXProp);
    ActiveXProp.Property.SetProperty('PortID', ActiveXProp);
    ActiveXProp.Property.Set_Prop_('PortID', ActiveXProp);
}
ActiveXInvite := myRDPSession.Invitations.CreateInvitation('RemoteSupport', 'WePresent', '12345', 75);

...

肯,

你的评论让我明白了。我从我自己的机器上重新生成了 TLB 文件,发现它确实有一个 属性 不在我最初使用的 TLB 中(来自 Jedi Project)。这个有一个名为 'Property' 的 属性,它允许我做我需要的事情。基本上我错过了 COM 接口点。以这种方式更新 TLB 后我让它工作了(还没有错误检查):

// get properties interface
myRDPSessionProp := myRDPSession.Properties;
// set listening port
myRDPSessionProp.Property['PortID'] := 59000;
// set color depth
myRDPSession.colorDepth := 8;
didShare := myRDPSession.Open;