Using COM Obejcts in Zorro

Posted By: turbodom

Using COM Obejcts in Zorro - 02/23/18 15:04

Hi. I'm struggling using classes from my C#.Net COM registered library. I wanna make use of <com.h> and the CoCreateInstance() method via my classe's Guids (interfaceid and classid). Here is some template code as far as I could make it. Can someone help me out with this code, it is not working when inserting my guids. Do I miss something? The Coinitilaize method is already returning no success.

#include <litec.h>
#include <com.h>


function Main()
{
// open the COM interface

HRESULT hr = CoInitialize(NULL);
if (hr!=S_OK)
{
printf("CoInitialize Failed: %xnn", hr);
return 0;
} else
printf("CoInitialize succeededn");

// define the GUIDs (Replace ? by real GUIDs)
GUID CLSID_MyObject;
IID IID_IFoo;
IIDFromStr("{????????-????-????-????-????????????}",&CLSID_MyObject);
IIDFromStr("{????????-????-????-????-????????????}",&IID_IFoo);

LPVOID *pIFoo;
// get a pointer to the class function table
hr = CoCreateInstance(&CLSID_MyObject, NULL, CLSCTX_ALL,&IID_IFoo, &pIFoo);
if (hr!=S_OK) {
printf("CoCreateInstance Failed: %xnn", hr);
return 0;
} else
printf("CoCreateInstance succeededn");

// use the class
//pIFoo->Func1();

// close the interface and exit
pIFoo->Release();
CoUninitialize();
}

Thank you very much in advance.
Posted By: AndrewAMD

Re: Using COM Obejcts in Zorro - 02/24/18 17:12

I am also interested in the answer to this question.

That said, it might be preferable to expose unmanaged C functions if it can be done in your application.
© 2024 lite-C Forums