Platform: VC 6.0, NT4.0
I created a class ImyObject which is derived from CCmdTarget as given below
static const GUID IID_IMyObject =
{ 0xe71032e0, 0x60e9, 0x11d1, { 0xb1, 0xaa, 0x0, 0x0, 0x21, 0x85, 0x0,
0x10 } };
interface IMyObject: public IUnknown
{
virtual HRESULT STDMETHODCALLTYPE GetObjectPointer(DWORD* pdwPtr)
= 0;
};
class CStorage : public CCmdTarget
{
public:
.
BEGIN_INTERFACE_PART(PersistStreamObj, IPersistStream)
...
END_INTERFACE_PART(PersistStreamObj)
BEGIN_INTERFACE_PART(MyObject, IMyObject)
STDMETHOD_(HRESULT,GetObjectPointer)(DWORD* pdwPtr);
END_INTERFACE_PART(IMyObject)
.
};
IMPLEMENT_SERIAL(CStorage, CCmdTarget, 0)
BEGIN_INTERFACE_MAP(CStorage, CCmdTarget)
INTERFACE_PART(CStorage, IID_IPersistStream, PersistStreamObj)
INTERFACE_PART(CStorage, IID_IMyObject, MyObject)
END_INTERFACE_MAP()
STATSTG memstat;
IPersistStream* pPersistStm = NULL;
CoCreateInstance(statstg.clsid, NULL, CLSCTX_ALL, IID_IPersistStream,
(void**)&pPersistStm);
IMyObject* pMyObject;
HRESULT h;
h = pPersistStm->QueryInterface(IID_IMyObject,(void**)&pMyObject);
Above code is reside in a DLL and it is being executed through global
function. My problem is that
1.. QueryInterface for IID_IMyObject is NULL i.e pMyObject is NULL when
call global function from non MFC application.
2.. It works fine when call function from MFC application
May I know the reason for that problem? Is there any initialization required
before to execute above code in non-MFC application?
Thanks in advance.
Regards
Vijay