Re: Creating DLL's
- Posted by Kat <gertie at PELL.NET> Feb 27, 2001
- 393 views
On 27 Feb 2001, at 10:02, matthewwalkerlewis at YAHOO.COM wrote: > > Well, I figured out how to create a DLL (and pass arbitrary sequences!) > using Eu/Eu2C (I've been using the PD version). To pass sequences, I used a > modified version of the (de)compress routines in database.e. I'm sending > the code to Rob, but here are the basics for creating a DLL: > > 1) Change the entry point by creating a function, DLLMain. DLLMain can be a > blank function that returns 1. > > BOOL WINAPI DLLMain(HINSTANCE hDLL,DWORD Reason,LPVOID Reserved) > { > > return 1; > }; > > 2) Modify WinMain as follows: > Change the declaration: > void __declspec(dllexport) Main_(void *hInstance) > > Comment out any references to argc or argv. These refer to command line > arguments, and shouldn't be used by the DLL. If your code uses command line > arguments, you'll probably want to create some functions to be called to > replace the command line args. You'll also need to comment out Cleanup(0) > at the end of WinMain, to allow the DLL to continue. > > 3) Export functions. You'll need to add __declspec(dllexport) to the > declarations of any functions you want to be called from outside the DLL. > When you import the function to Eu, you'll need to add a '_' to the > beginning: > > If you have: > int __declspec(dllexport) foo() > > Then in your Eu program: > bar = define_c_func( dllname, "_foo", {}, C_INT) > > 4) Change the makefile to compile a DLL. I've only done this with Borland. > You'll need to check the manual of your compiler to see how to compile a > DLL. The second line of emake.bat will begin: > > @bcc32 -tW .... > > Change this to: > @bcc32 -tWD ... > > and Borland will compile your code into a DLL. > > 5) You may need to make/remove dummy function calls to keep the translator > from optimizing routines away. Just comment these out as appropriate. How i long for the days when i could click on the Compile button (i think it was F9 too) in the Turbo Pascal IDE and get a stand-alone exe that ran perfectly fine. All those parameters and macros were stored, and could be reconfigured with a popup check box. Speaking of retro code and OSs, how compatable will the Eu dos gui be to win3.11? The pascal ide turned out a copycat gui of win3.x, altho i still think it was MS that stole that look and feel from Borland. Kat