Computing.Net > Forums > Programming > Can anyone convert a tiny C++ DLL?

Can anyone convert a tiny C++ DLL?

Reply to Message Icon

Original Message
Name: MacFromOK
Date: December 25, 2002 at 15:55:48 Pacific
Subject: Can anyone convert a tiny C++ DLL?
OS: Windows
CPU/Ram: AMD w/128mb RAM
Comment:

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


Report Offensive Message For Removal


Response Number 1
Name: MacFromOK
Date: December 25, 2002 at 15:57:54 Pacific
Reply: (edit)

The #include file is windows.h...

Cheers, Mac


Report Offensive Follow Up For Removal

Response Number 2
Name: MacFromOK
Date: December 27, 2002 at 07:49:13 Pacific
Reply: (edit)

Got it converted!

Thanks, Mac


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Can anyone convert a tiny C++ DLL?

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge