Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 838 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Using COM Obejcts in Zorro #471212
02/23/18 15:04
02/23/18 15:04
Joined: Feb 2016
Posts: 5
Stuttgart
turbodom Offline OP
Newbie
turbodom  Offline OP
Newbie

Joined: Feb 2016
Posts: 5
Stuttgart
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.

Re: Using COM Obejcts in Zorro [Re: turbodom] #471234
02/24/18 17:12
02/24/18 17:12
Joined: Feb 2017
Posts: 1,731
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,731
Chicago
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.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1