I need help converting this "C++" DLL code to
straight "C", so it can compile with either LCC,
DevCpp, or the MinGW compiler.
Here's why:
This DLL code must NOT generate underscores
to work with the VDS scripting language. It
compiles under Borland C++ Builder 5, but using
"underscores off" kills many of the standard
C/C++ functions such as atoi, etc. (I can use
the VCL, but it bloats the DLL to 100k).
I have been told that LCC and GCC based compilers
do NOT generate underscores for straight C code,
but I haven't been able to convert this to
straight C.
Here's also a link to a zip file that contains
the CPP file, the compiled DLL file, and an
integrated EXE that runs it (so if ya convert it
to C and test it, you'll know what to expect):
http://www.trinex.net/users/mac/vdsfiles/test.zip
Everything is in this code (no other headers).
I have a similar Delphi example if that would
help anyone...
____________________________________________________________________________________________________
#include
typedef void __cdecl (*exteventproc)(char * eventtype);
#define MAX_PAR 4; // maximum number of parameters of a command or function
#define BUF_LEN 256; // length of transfer buffer
int AHandle; // int window handle passed by VDS (worthless)
exteventproc eventproc; // address of event notification procedure
int errorcode = 0; // error code
extern "C" __declspec(dllexport) char * __cdecl Init(int Handle, exteventproc Addr, char * KeyString, int &maxpar, int &bufsize);
extern "C" __declspec(dllexport) int __cdecl CommandProc(char * Params);
extern "C" __declspec(dllexport) char * __cdecl FuncProc(char * Args);
extern "C" __declspec(dllexport) int __cdecl StatProc(void);
-------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
if(reason == DLL_PROCESS_ATTACH) // Runs this code when DLL has loaded...
{ MessageBox(NULL, "DLL Loaded", "TEST.DLL", MB_OK);
}
if(reason == DLL_PROCESS_DETACH) // and this when VDS program terminates.
{ MessageBox(NULL, "DLL Unloading", "TEST.DLL", MB_OK);
}
return 1;
}
char * __cdecl Init(int Handle, exteventproc Addr, char * KeyString, int &maxpar, int &bufsize)
{
AHandle = Handle;
eventproc = Addr;
maxpar = MAX_PAR;
bufsize = BUF_LEN;
return "TEST"; // Command and function name
}
int __cdecl CommandProc(char * Params)
{
MessageBox(NULL, "Command procedure works", "TEST.DLL", MB_OK);
eventproc("Event Test"); // Set @event()
return 0;
}
char * __cdecl FuncProc(char * Args)
{
MessageBox(NULL, "Function procedure works", "TEST.DLL", MB_OK);
return Args;
}
int __cdecl StatProc(void)
{
return errorcode;
}
____________________________________________________________________________________________________
Thanks, and Happy Holidays!
Cheers, Mac