Generally, what I'm trying to do is to make a very basic package to create and communicate with COM components on Windows, mostly as an exercise :-) I found this library:
http://disphelper.sourceforge.net/ as a great start, so you don't have to fiddle with OLE/COM headaches.
The problematic function in C is defined as:
__declspec(dllexport) void CallMethod(void* myObj) {
...
}
It takes a pointer to a COM object, which was previously returned by
__declspec(dllexport) void* CreateObject(char* szProgId) {
...
IDispatch * myObj = NULL
...
return &myObj;
}
So, CreateObject() creates COM object and returns a pointer to it, CallMethod() takes this pointer and tries to communicate with it.
My error was in returning a pointer to a pointer ... since IDispatch * myObj = NULL was actually hidden in a macro and I missed its true definition, huh.