GIT always return 0 to the registered interface pointer 
Author Message
 GIT always return 0 to the registered interface pointer

CoInitializeEx(  NULL, COINIT_MULTITHREADED  );

        CoCreateInstance(CLSID_StdGlobalInterfaceTable, NULL,
CLSCTX_INPROC_SERVER, IID_IGlobalInterfaceTable, (void **)&gpGIT) ;
        CoCreateInstance(CLSID_RemoteTime, NULL, CLSCTX_INPROC_SERVER,
IID_IRemoteTime, (void **)&m_pTimer) ;
        gpGIT->RegisterInterfaceInGlobal((IUnknown *) m_pTimer,
CLSID_RemoteTime, &pdwCookie);
        IRemoteTime* pInterface;
        gpGIT->GetInterfaceFromGlobal( pdwCookie, CLSID_RemoteTime,
reinterpret_cast<void**>(&pInterface) );

I can use "m_pTimer" to call methods of the COM server. But in the
above sample, "pInterface" is always 0.

Any one what's wrong?

Thanks.



Fri, 23 Jul 2004 08:08:48 GMT  
 GIT always return 0 to the registered interface pointer
Hi,

1. Based on my experience and research, I found that the problem is caused
by call the RegisterInterfaceInGlobal() function with an inappropriate
parameter value.

gpGIT->RegisterInterfaceInGlobal((IUnknown *) m_pTimer,CLSID_RemoteTime,
&pdwCookie);

As in the above code, the second parameter should be of the IID of the
interface instead of class id(CLSID_RemoteTime). So as in this case, we can
change the code as the following:

gpGIT->RegisterInterfaceInGlobal((IUnknown *) m_pTimer, IID_IRemoteTime,
&pdwCookie);

2. It's the same with the GetInterfaceFromGlobal method.

3. I'd like to recommend the following articles for your further reference:
http://msdn.microsoft.com/library/en-us/com/cmi_d2l_77e4.asp
http://msdn.microsoft.com/library/en-us/com/cmi_d2l_7lt8.asp

Hope this helps!

Regards,
HuangTM

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.



Fri, 23 Jul 2004 10:55:35 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. GIT fails returning registered interface pointer

2. CoCreateInstance returns 0x80040155 (Interface not registered) after instanciating a class object

3. return a pointer, always get 0000 as its segment

4. signal() always returns a callable function pointer?

5. how many GIT pointers per process?

6. Returning Interface Pointers...

7. Anyone know how to return / pass Interface Pointers

8. COM: Returning pointer to an interface...

9. Pointer to function returning pointer to function returning...

10. Pointers: return of pointer to array of pointers to main

11. Interface with Interface pointer from imported type library as argument

12. Communication between interfaces, CoCreateInstance and interface pointers.

 

 
Powered by phpBB® Forum Software