gpt4 book ai didi

delphi - 在 Delphi 中设置 COM (RDPEncomAPI) 属性

转载 作者:行者123 更新时间:2023-12-02 02:16:45 24 4
gpt4 key购买 nike

我已经使用 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);

...

最佳答案

肯,

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

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

关于delphi - 在 Delphi 中设置 COM (RDPEncomAPI) 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30649613/

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