【问题标题】:Setting COM (RDPEncomAPI) property in Delphi在 Delphi 中设置 COM (RDPEncomAPI) 属性
【发布时间】:2015-06-06 01:18:37
【问题描述】:

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

如何获取和设置 RDPSession.Properties 的 PortID 属性?

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);

...

【问题讨论】:

  • RDPSession.Properties的定义是什么? (它是如何在 IRDPSession 的源代码中声明的?)我怀疑它是 Variant (这可能意味着一个 Variant 数组)或某种集合;无论哪种方式,它都是复数,这意味着有多个条目,这意味着对内容进行某种迭代。
  • Ken: TLB 单元中的 RDPSession.Properties 它是一个 IDispatch 接口,没有定义实际属性,但具有 Get_Property_ 和 Set_Property_ 函数。根据 MSDN,Get 和 Set 是获取属性的唯一方法。不幸的是,我无法以这种方式获取或设置它们。

标签: delphi com rdp


【解决方案1】:

肯,

你的评论让我想到了一些东西。我从自己的机器上重新生成了 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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-23
    • 2019-12-13
    • 1970-01-01
    相关资源
    最近更新 更多