|
|
Re: COM Interface @jcl
[Re: jcl]
#148027
08/16/07 14:20
08/16/07 14:20
|
Joined: Jul 2006
Posts: 783 London, UK
sheefo
OP
User
|
OP
User
Joined: Jul 2006
Posts: 783
London, UK
|
Thanks. I am not understanding whats in picture.h. It's different from the manual. Here is the definition: Code:
typedef struct _IObject1Vtbl { // IUnknown methods long __stdcall QueryInterface(long, long riid, void *ppvObject); long __stdcall AddRef(long); long __stdcall Release(long);
// IObject1 methods long __stdcall get_GetANum(long, long* pVal); } IObject1Vtbl; typedef interface _IObject1 { IObject1Vtbl *lpVtbl; } IObject1;
This is how I initialize it (just like in the manual): It returns the error code in the CoCreateInstance function. Code:
#include <litec.h> #include <com.h>
IFoo *pIFoo;
int WinMain() { HRESULT hr; hr = CoInitialize(NULL); GUID CLSID_MyObject; IID IID_IFoo;
// I DONT KNOW WHAT TO PUT HERE, NO MATTER WHAT I PUT IT DOESN'T WORK: IIDFromStr("{????????-????-????-????-????????????}",&CLSID_MyObject); // "{8D72F083-9925-4DCE-94E9-CDBD933DDACB}"???
IIDFromStr("{67E3E462-F3C0-48A6-8758-161CEE83D547}",&IID_IFoo); if (hr!=S_OK) { printf("CoInitialize Failed: %x\n\n", hr); return 0; } else { printf("CoInitialize succeeded\n"); }
// THIS RETURNS ERROR CODE 80040154 hr = CoCreateInstance(&CLSID_MyObject, NULL, CLSCTX_ALL,&IID_IFoo, &pIFoo); if (hr!=S_OK) { printf("CoCreateInstance Failed: %x\n\n", hr); } else { printf("CoCreateInstance succeeded\n"); } CoUninitialize(); }
|
|
|
Re: COM Interface @jcl
[Re: jcl]
#148031
08/16/07 17:26
08/16/07 17:26
|
Joined: Jul 2006
Posts: 783 London, UK
sheefo
OP
User
|
OP
User
Joined: Jul 2006
Posts: 783
London, UK
|
I guess I got the GUID's right, because I got this: "CoCreateInstance succeeded"  The function executes, but it sets the variable to 1 instead of 101... I wonder why. Anyway, I'll solve it later. Thank you so much. You are the best! I appreciate your time and help. PS: I know more about COM than Win32 DLL's (and I know next to nothing about COM). Also, I like classes and this is the only way to use them in LiteC.
|
|
|
|