views:

287

answers:

0

Recently I've tried to solve several different issues with CoRegisterClassObject (because its introduction on MSDN looks pretty nice) - unfortunately it never works for me. Am I doing something wrong? Here's what I've tried:

(1) Use CoRegisterClassObject for proxy/stub objects: I have a downloaded COM server (in DLL) with its proxy/stub (in another DLL) which I want to use it without install (and I do need marshaling so proxy/stub is required); so I created the proxy/stub by loading + DllGetClassObject from its DLL and got an IClassFactory, feed into CoRegisterClassObject, and then CoRegisterPSClsid - every API return success.

However when I started marshaling, it just failed - the document said I have to register it for "every apartment"; I don't know if this is the reason (how do I check?) and I can't determine the client's apartment (because it's another DLL by others) - can I just declare the class object as "thread model = both" and make it work for every apartment?

There's also a magical CLSCTX_PS_DLL in CoRegisterClassObject - is this what I need? (but when passing it, the return value is always E_INVALDARG).

(2) Use CoRegisterClassObject to override a COM: I want to force Windows Media Player to use my filter but I don't want to change the system default settings, so I wanted to use CoRegisterClassObject to pretend my filter is the default. However it does not work again - maybe apartment issue again?

So is there any method to do a global registration in one process?

(I also checked the side by side / active context API - but it does not allow me to assign things easily...)