标签: queryinterface

Delphi的支持 - > QueryInterface访问冲突异常

我有以下代码:

  for i := 0 to FControlList.Count - 1 do
      if Supports(IMyControl(FControlList[i]), IMyControlEx) then
      begin
        MyControlEx := IMyControl(FControlList[i]) as IMyControlEx;
        MyControlEx.DoYourMagic(Self, SomeData);
      end;
Run Code Online (Sandbox Code Playgroud)

在我的应用程序执行期间多次调用此代码,但在某些特定情况下,它在Supports()方法中失败.更具体地说 - 它似乎属于Supports()方法中的QueryInterface()调用.

我检查了FControlList不是nil而FControlList [i]不是nil并且它仍然发生.

任何想法将不胜感激!

delphi queryinterface access-violation

1
推荐指数
1
解决办法
1038
查看次数

方法中的参数太多...(从Delphi XE中的WSDL连接到WebService)

有一个外部Web服务,分别要求客户端给他.基于shell Embarcadero的WSDL标准RAD Studio XE(Delphi XE)创建了一个通常运行良好的单元,但在这种情况下有一个警告 - 其中一个函数转移到100多个参数.当您在运行时创建用于调用Web服务的对象时,会收到错误"方法'方法名称中的参数太多'".如果参数的数量减少到61,那么一切都开始工作 - 调用Web服务运行正常并返回响应.为什么会这样?转向互联网,但结果为零.

delphi wsdl web-services queryinterface delphi-xe

1
推荐指数
1
解决办法
748
查看次数

配置Mongoid关系以返回已排序的对象

我有两个关系为1-n的课程.像这样:

class Band
  include Mongoid::Document
  has_many :members
end

class Member
  include Mongoid::Document
  field :name, type: String
  field :joined, type: Date
  belongs_to :band
end
Run Code Online (Sandbox Code Playgroud)

现在,当我打电话时,band.members我得到了成员对象.我想要的是,如果我打电话band.members.last来获得加入最后一个的成员.我通过定义基于以下的<=>方法Member和排序来实现这一点joined:

band.members.sort.last
Run Code Online (Sandbox Code Playgroud)

如何将此行为设为默认值?我不想避免额外的排序调用.这是可能的,如果可以,怎么样?

ruby dsl queryinterface mongodb mongoid

1
推荐指数
1
解决办法
1440
查看次数

在COM中绝对必须调用QueryInterface()吗?

C ++ / COM Shell扩展教程中,程序员演示了(出于启发目的)您可以放弃调用,QueryInterface()而只是传递一个通用对象。至少在实施时有效DllGetClassObject()。他说,的目的QueryInterface()仅仅是让每个对象自己说出是否支持给定的接口。

与此同时,微软似乎的是QueryInterface()要获得一个指向特定接口的对象上。

那么到什么程度是QueryInterface()必要的?有什么时候调用QueryInterface()绝对必要的,没有它,代码将无法工作?还是像视频教程所建议的那样,使对象本身在技术上足够?

c++ com winapi shell-extensions queryinterface

1
推荐指数
1
解决办法
159
查看次数

有人在使用QueryInterface在Delphi中注意到这种行为吗?

这是我的类型......

unit unitTestInterfaces;

interface
type
  IFoo = interface
    ['{169AF568-4568-429A-A8F6-C69F4BBCC6F0}']
    function TestFoo1:string;
    function TestFoo:string;
  end;

  IBah = interface
    ['{C03E4E20-2D13-45E5-BBC6-9FDE12116F95}']
    function TestBah:string;
    function TestBah1:string;
  end;

  TFooBah = class(TInterfacedObject, IFoo, IBah)
    //IFoo
    function TestFoo1:string;
    function TestFoo:string;

    //IBah
    function TestBah1:string;
    function TestBah:string;
  end;

implementation

{ TFooBah }

function TFooBah.TestBah: string;
begin
  Result := 'TestBah';
end;

function TFooBah.TestBah1: string;
begin
  Result := 'TestBah1';
end;

function TFooBah.TestFoo: string;
begin
  Result := 'TestFoo';
end;

function TFooBah.TestFoo1: string;
begin
  Result := 'TestFoo1';
end;

end.
Run Code Online (Sandbox Code Playgroud)

这是运行示例的代码...

var
  fb:TFooBah;
  f:IFoo; …
Run Code Online (Sandbox Code Playgroud)

delphi queryinterface

0
推荐指数
1
解决办法
314
查看次数