Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the GIT in Delphi 7?

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;

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

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

like image 357
Rocky Luck Avatar asked Dec 10 '22 20:12

Rocky Luck


1 Answers

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.
like image 196
3 revs, 3 users 93% Avatar answered Dec 29 '22 00:12

3 revs, 3 users 93%