Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 1,170 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
DLL call problems... #300133
11/30/09 05:40
11/30/09 05:40
Joined: Mar 2009
Posts: 5
P
peonytele Offline OP
Newbie
peonytele  Offline OP
Newbie
P

Joined: Mar 2009
Posts: 5
hi everyone:
i have some problems when i call a DLL in A7:
first, there is another DLL written by VS2003,just simple example,code like this:
testDLL.cpp:
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <tchar.h>
#include "testDLL.h"
int WINAPI testMax(int a, int b)
{
return a;
}

testDLL.def:
LIBRARY qq
EXPORT
testMax @ 1

then,i wrote a main DLL which is for the Engine to call.code like this:

MyDLL.cpp:
#define DLL_USE
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <tchar.h>
#include "adll.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
engine_bind();
return TRUE;
}
DLLFUNC var testDll()
{
typedef int( * test)(int, int);
HINSTANCE hDLL;
test testMax;
int result;
hDLL = LoadLibrary("qq.dll");
if(hDLL != NULL)
{
testMax = (test)GetProcAddress(hDLL, "testMax");
if(testMax != NULL)
{
result = testMax(1, 0);
FreeLibrary(hDLL);
return _VAR(result);
}
else
return _VAR(3);
}
else
{
return _VAR(4);
}
}

both DLL was complied with no errors,and i got 2 DLL files:
qq.dll,MyDll.dll,i just put them in the same path.
when i call the function in Lite-C:

var deadpoint = 0;
deadpoint = testDll();

the deadpoint`s value is always 3,that means the GetProcAddress function has a NULL return value?
that is the problem i want to solve...hope someone could help,thanks!!

Re: DLL call problems... [Re: peonytele] #300270
12/01/09 02:40
12/01/09 02:40
Joined: Nov 2009
Posts: 34
S
Sepiantum Offline
Newbie
Sepiantum  Offline
Newbie
S

Joined: Nov 2009
Posts: 34
Go make a new project in vs2003. Then make it a win32 console application and make sure it is a dll library. Write some functions in it, and build it. It should build these two files if I am not mistaken: nameofproject.dll and nameofproject.lib. Then, all you need to do is go to lite-c and write #pragma comment("nameofproject.lib"). No semicolon, remember that you don't use semicolons with preprocessor directives. And make sure to put nameofproject.lib where lite-c locates library functions and put nameofproject.dll where lite-c loads dll libraries. BUT, if you publish your game, you will need to put nameofproject.dll where acknex.h is.

I'm pretty sure that is how you load a dll.

Re: DLL call problems... [Re: Sepiantum] #300274
12/01/09 05:16
12/01/09 05:16
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Usually lite-c loads all dlls in it's PLUGIN_DIR directory. All you need to use the functions is a function prototype.

There is more information here...

http://www.opserver.de/wiki/index.php/Writing_a_basic_DLL

Re: DLL call problems... [Re: DJBMASTER] #300277
12/01/09 06:27
12/01/09 06:27
Joined: Mar 2009
Posts: 5
P
peonytele Offline OP
Newbie
peonytele  Offline OP
Newbie
P

Joined: Mar 2009
Posts: 5
thank you guys!
i have tried, still failed...
but, i used static link to the dll, it passed.just put qq.dll, qq.lib and testDll.h in the MyDll path, and include testDll.h, link qq.lib in MyDll project...
is there any success example which use dynamic link to the dll?...


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