Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
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]

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us