Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by AndrewAMD. 12/05/23 10:56
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 622 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
COM Interface #148024
08/15/07 13:32
08/15/07 13:32
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
I have a working COM DLL, how do I include it in LiteC? Is there a function to include it or a special directory to put it?

COM Interface @jcl [Re: sheefo] #148025
08/16/07 13:25
08/16/07 13:25
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
PLEASE! One of the reasons I bought A7 was because I thought it could support COM.

Whether or not my DLL exists I get the same error (80040154). Thats why there must be some way to tell LiteC to use it. How do I include my DLL? The only person I can think of that can answer this is jcl. Please jcl!!!
I have followed the manual exactly (the only difference is I replaced the question marks with the uuid of my class).

Re: COM Interface @jcl [Re: sheefo] #148026
08/16/07 13:54
08/16/07 13:54
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
You can look up the error number in the VC++ error tool. Maybe you've forgotten to call CoInitialize or something like that, but not knowing what you are doing I can't be of much help, naturally. Writing and implementing COM DLLs requires some experience in C++ programming and debugging.

You can find many examples of include files that implement COM DLLs. For instance, have a look at the d3d9.h file that implements DirectX, and also check out com.h and picture.h for getting the idea.

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 Offline OP
User
sheefo  Offline 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: sheefo] #148028
08/16/07 15:22
08/16/07 15:22
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
You must register your class before calling CoCreateInstance. In the manual the "{????????-????-????-????-????????????}" just means 'put your GUID here' - you must not give question marks but a real registered CLSID.

I still don't know what you intend to do but if you've got a COM DLL you should also know its GUIDs and have received instructions or examples about how to bind it to a program. CoCreateInstance and GUIDs are nothing special to lite-C, but standard MFC methods for creating instances of registered classes on your PC.

Re: COM Interface @jcl [Re: jcl] #148029
08/16/07 16:02
08/16/07 16:02
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
How do I register the class and get the CLSID? Do I do this in VC++ or what?

I really appreciate the help, thanks.

BTW, All my DLL does is have a class with one function which sets a variable to a value of 101. I just want to experiment.

Re: COM Interface @jcl [Re: sheefo] #148030
08/16/07 16:18
08/16/07 16:18
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
When you create the COM DLL with the VC++ Wizard, it's normally registered automatically. Otherwise you need to manually enter it into the registry.

You can read the GUIDS out of the IDL code of your DLL. Alternatively, you can use regedit and search for the name of your project to read the GUIDs out of the registry. You need to know both GUIDs, one for the class (the CLSID) and one for the interface.

However I suggest that you read some literature about the COM model before. This is definitely not beginner's stuff and it makes not much sense to continue if you are not familiar with the basic concepts. I don't know why you need COM, but maybe a plain Win32 DLL will do also? This is easier.

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 Offline OP
User
sheefo  Offline 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.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1