|
|
|
date: 17 May 2006 08:16:33 -0700,
group: microsoft.public.platformsdk.ui_shell
back
CoCreateInstance function returns NULL
Hi All,
I'm trying to access some classes than an OLE server expose,
I know the CLSID of such classes because they are placed in Windows
Registry.
I use the CoCreateInstance function:
STDAPI CoCreateInstance(
REFCLSID rclsid, //Class identifier
LPUNKNOWN pUnkOuter, //Object is or isn't part of an aggregate
DWORD dwClsContext, //Context for running executable code
REFIID riid, //Interface identifier
LPVOID * ppv //Pointer to storage of interface pointer
);
This is the program I use in Borland C++ 5 to instance a class
LPVOID ppv;
CLSID pclsidobjeto={0x12345678, 0x1234, 0x1234,0x1234,0x123456789ABC}
CoCreateInstance(pclsidobjeto,NULL,CLSCTX_ALL,IID_IClassFactory,&ppv);
this function should return a pointer to an object of the class
instantiated
on ppv but it returns NULL.
AnyBody could tell me where is the error or if there is another way
to instance the class?
Thanks,
date: 17 May 2006 08:16:33 -0700
author: nagar
Re: CoCreateInstance function returns NULL
1. Try checking the HRESULT returned by CoCreateInstance
It should provide you with the explanation what is wrong. YOu may also try
GetLastError and see what error it returns...
2. Are you sure that the object you are trying to create supports
IID_IClassFactory interface? Try IID_IUnknown...
--
Regards,
Yuriy
This posting is provided "AS IS" with no warranties, and confers no rights.
"nagar" wrote in message
news:1147878993.766390.115630@j33g2000cwa.googlegroups.com...
> Hi All,
> I'm trying to access some classes than an OLE server expose,
> I know the CLSID of such classes because they are placed in Windows
> Registry.
>
> I use the CoCreateInstance function:
> STDAPI CoCreateInstance(
> REFCLSID rclsid, //Class identifier
> LPUNKNOWN pUnkOuter, //Object is or isn't part of an aggregate
> DWORD dwClsContext, //Context for running executable code
> REFIID riid, //Interface identifier
> LPVOID * ppv //Pointer to storage of interface pointer
> );
>
>
> This is the program I use in Borland C++ 5 to instance a class
> LPVOID ppv;
> CLSID pclsidobjeto={0x12345678, 0x1234, 0x1234,0x1234,0x123456789ABC}
> CoCreateInstance(pclsidobjeto,NULL,CLSCTX_ALL,IID_IClassFactory,&ppv);
>
>
> this function should return a pointer to an object of the class
> instantiated
> on ppv but it returns NULL.
>
>
> AnyBody could tell me where is the error or if there is another way
> to instance the class?
>
>
> Thanks,
>
date: Mon, 5 Jun 2006 01:05:42 -0700
author: Yuriy Shkolnikov [MSFT]
|
|