如何获得GIT在Delphi 7? [英] How to get the GIT in Delphi 7?

查看:794
本文介绍了如何获得GIT在Delphi 7?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过使用以下代码(Delphi)获取全局接口表:

I'm trying to get the Global Interface Table by using the following code (Delphi):

uses Comobj, ActiveX;

var
   cGIT : IGlobalInterfaceTable = NIL;
const
   CLSID_StdGlobalInterfaceTable: TGUID = '{00000146-0000-0000-C000-000000000046}';


function GIT : IGlobalInterfaceTable;
begin
   if (cGIT = NIL) then
      OleCheck (CoCreateInstance (CLSID_StdGlobalInterfaceTable, NIL,
                                  CLSCTX_ALL, IGlobalInterfaceTable, cGIT ));
  Result := cGIT;
end;

但是,CoCreateInstance会抛出未注册类异常。确实:在HKCR / CLSID中没有{00000146-等}的条目。

However, CoCreateInstance throws a "Class Not Registered" exception. And indeed: in HKCR/CLSID there is no entry for {00000146- etc. }.

应该注册哪个dll或ocx,以在注册表中获取此定义?
或者我完全错了?

Which dll or ocx should be registered, to get this definition in the registry? Or am I doing it totally wrong?

推荐答案

这是我的单位。我把这一起在我在D2006编译时,但我不明白为什么它将是任何不同的D7。我使用它来存储到DCOM服务器的接口并在多个线程之间共享它。

Here's my unit that does it. I put this together when I was compiling in D2006, but I don't see why it would be any different in D7. I use it for storing an interface to a DCOM server and sharing it between multiple threads.

unit GlobalInterfaceTable;

interface

uses Types,
     ActiveX;

type
  IGlobalInterfaceTable = interface(IUnknown)  
     ['{00000146-0000-0000-C000-000000000046}']  
     function RegisterInterfaceInGlobal (pUnk : IUnknown; const riid: TIID; out dwCookie : DWORD): HResult; stdcall;  
     function RevokeInterfaceFromGlobal (dwCookie: DWORD): HResult; stdcall;  
     function GetInterfaceFromGlobal (dwCookie: DWORD; const riid: TIID; out ppv): HResult; stdcall;  
   end;

  function GIT: IGlobalInterfaceTable;

implementation

uses ComObj;

const
  CLSID_StdGlobalInterfaceTable : TGUID = '{00000323-0000-0000-C000-000000000046}';

function GIT: IGlobalInterfaceTable;  
begin  
  // This function call always returns the singleton instance of the GIT  
  OleCheck(CoCreateInstance (CLSID_StdGlobalInterfaceTable, NIL, CLSCTX_ALL, IGlobalInterfaceTable, Result));  
end;

end.

这篇关于如何获得GIT在Delphi 7?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆