Hello, everyone. For the past week I have been trying to use a dll in Lite-C but can't seem to get it to work.
I just need to be able to call 2 functions from the dll:
unsigned int InitSystem(int argc, char * argv[],char* unchangedPath = NULL,char* readonlyPath = NULL, char* writablePath = NULL);
void PerformChat(char* user, char* usee, char* incoming,char* ip,char* output);
Bruce Wilcox has been kind enough to make me a dll for his ChatScript, and has been helping me to get this to work in Lite-C but I don't know much about dll's and can't get this to work. I have used other dll's such as Anet, but all I had to do was dump the dll and .h file in my game's folder and include the .h in my code. I have never actually had to make a .h file myself for a dll.
Getting back to the basics I am not trying to include it in my own project, rather just made a new test project folder and dumped the dll file in there. My current "test.c" file looks like this:
#include <acknex.h>
#include <windows.h>
unsigned int WINAPI InitSystem(int argc, char** argv,char* unchangedPathL,char* readonlyPath, char* writablePath);
void WINAPI PerformChat(char* user, char* usee, char* incoming,char* ip,char* output);
long ChatScript_h;
STRING* chatscript_answer;
void main()
{
fps_max=60;
level_load(NULL);
//while(!GetModuleHandle("ChatScript.DLL")){wait(1);}
ChatScript_h = LoadLibrary("ChatScript.DLL");
InitSystem = GetProcAddress(ChatScript_h,"InitSystem");
PerformChat = GetProcAddress(ChatScript_h,"PerformChat");
chatscript_answer=str_create("#128");
InitSystem(0,NULL,NULL,NULL,NULL);
PerformChat(_chr("Carlos"),_chr("Harry"),_chr("Hello"),NULL,_chr(chatscript_answer));
while(1)
{
wait(1);
}
}
Can anyone help me spot what I am doing wrong? When I try to run the code I get an Error E1513 Script Crash in Main.
I have commented out "while(!GetModuleHandle("ChatScript.DLL")){wait(1);}" because it always returns 0 and gets stuck there.
It seems the dll is never loading? Do I have to use any other function before all that to open the dll?
Here is the relevant contents of my acklog.txt
Mouse found
Altavoces (Dispositivo de High Definition Audio) opened
NVIDIA GeForce GT 610 pure T&L device 1ff9 detected
D3D device NVIDIA GeForce GT 610 1ff9 selected.
ackAR.dll opened
acknet.dll opened
ackoal.dll opened
ackphysx.dll opened
ackwii.dll opened
Compiling TEST2.C - [Esc] to abort.....
InitSystem: function not found
PerformChat: function not found.... 0.302 sec
Running TEST2.C.
2 objects
Main started at 1.400 in debug mode
D3D_Init Window: 800x600 -> Window: 1x800x600x32
Video memory found: 3787 MB
LevelInit at 1.434 0 lmaps 0 textures...ok
LevelReady at 1.438
Error E1513: Script crash in main:
Main loop at 2.899....
1st frame with 3787 MB. at 2.903
Normal exit at 4.385
Close level,DLL,objects
I don't see "ChatScript.DLL" in that acklog either... I guess it is not opening the dll... (both "test.c" and "ChatScript.DLL" are in the same folder).
Any help with this would be great
EDIT: If anyone would like to see the original conversation with Bruce you can find it at the chatscript forums here:
http://www.chatbots.org/ai_zone/viewthread/1552/P15/