How to get GIT in Delphi 7?

I am trying to get a global interface table 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 exception without registering. And really: there is no entry in the HKCR / CLSID for {00000146-, etc.}.

What dll or ocx must be registered to get this definition in the registry? Or am I doing this completely wrong?

+4
source share
3 answers

Here is my unit that does this. I put this together when I compiled in D2006, but I don’t understand why in D7 it would be different. I use it to store the interface for a DCOM server and share 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. 
+7
source

You incorrectly defined CLSID_StdGlobalInterfaceTable: you specified the GUID of the interface, not a specific class.

I do not have Windows header files, so I can not check them, but the search suggests that this should be:

  CLSID_StdGlobalInterfaceTable: TGUID = '{00000323-0000-0000-C000-000000000046}'; 
+5
source

Have you used OleView32 to verify the class GUID? This utility is available in the Windows SDK and allows you to maintain a registry of interfaces much easier than regedit. I would classify the utility as a must for any COM development.

+2
source

All Articles