1、GetInterface通过类信息查是否有该支持接口,简单点说就中只能要到
Class=(TXXXX,Interface1,...interfacen);
后面的Interface
2、QueryInterface依赖实现者,即使类没有这个接口,实现者可以返回另外的一个对象。
DELPHI中事件的派送便是一例
function TForm2.QueryInterface(const IID: TGUID; out Obj): HRESULT;
begin
// We need to return the event interface when it's asked for
Result := E_NOINTERFACE;
if GetInterface(IID, Obj) then
Result := S_OK;
if IsEqualGUID(IID, IEventIntfEvents) and GetInterface(IDispatch, Obj) then
Result := S_OK;
end;
纵上所述:GetInterface由编译器去实现,QueryInterface由方法实现都去决定。