For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > December 2005 > Cocreateinstance failed









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Cocreateinstance failed
MadeleineP

2005-12-15, 6:55 pm

Dear All,

I already create the ActiveX DLL and try to call it in my Visual C. My
problem is the calling function does not work in some of my computers. I will
write out some steps that I did:

1) I go to regedit and type : regsvr32 dllname.dll
2) Here is the calling function in Visual C
BOOLEAN rv = TRUE;
char buf[BUFSIZ];
HRESULT hresult;
CLSID clsid;
_clsVBCreateRelation *ptr = NULL;

CoInitialize(NULL); //initialize COM library
hresult=CLSIDFromProgID(OLESTR("VBCreateRelation.clsVBCreateRelation"),
&clsid); //retrieve CLSID of component

hresult=CoCreateInstance(clsid,NULL,CLSC
TX_INPROC_SERVER,__uuidof(_clsVBCreateRe
lation),(LPVOID *) &ptr);
if(FAILED(hresult))
xvt_dm_post_note("Create cascade update for tables LIM and LIM_POINTS
relation failed");
else if (ptr)
{
sprintf(buf, "%s.mdb", x->connect.filename);
rv = ptr->VBCreateLimPoints((_bstr_t)buf);
if(!rv)
xvt_dm_post_note("Create cascade update for tables LIM and
LIM_POINTS relation failed");
ptr->Release(); //call method
}
CoUninitialize(); //Unintialize the COM library

*****the faillure message is from the function CoCreateInstance

Please help me,,,Thank

Michael C

2005-12-15, 6:56 pm

"MadeleineP" <MadeleineP@discussions.microsoft.com> wrote in message
news:EE323625-9646-44BD-A81F-
> CoInitialize(NULL); //initialize COM library
> hresult=CLSIDFromProgID(OLESTR("VBCreateRelation.clsVBCreateRelation"),
> &clsid); //retrieve CLSID of component


You're not cheching the hresult here. Did CLSIDFromProgID fail or did
CoCreateInstance fail? Does it work if you hard code the clsid? Also, does
it work on those machines if you try to create the object in a vb6 exe or in
excel?

Michael


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com