MYDLL.ZIP - An example Windows DLL project for C/C++ developers
Developers, this is a sample project which demonstrates the very basics to
wrapping functions in a Windows Dynamic Link Library (DLL). It's a completely
worthless library in itself, but it demonstrates the procedures and styles you
should follow when constructing your own DLLs.
There are typically six files associated with any DLL project:
1) The project make file (.MAK)
2) The function declarations file (.H)
3) The function definitions file (.C)
4) The project definition file (.DEF)
5) The import link library file (.LIB)
6) The DLL file (.DLL)
You have to create the first four files. When you build the project, the
linker creates the link library and the DLL file. The link library does not
contain the object code for your functions, but instead contains a small loader
routine for each function, which resolves the reference to the function in the
DLL at runtime.
DLLs you create this way are language-neutral. You can call functions in the
DLL from any language which supports DLLs, including Visual Basic, Microsoft
Access, Turbo Pascal, and others. You will have to write your own function
declarations for the language you're using, but that's fairly easy.
Note: NEVER change the order of functions in your module definition file.
The import library file identifies functions in DLLs by their ordinal position,
which is dicatated by the order the functions are listed in the .DEF file.
Changing the order is just asking for trouble. Your new version of the DLL
will not cooperate with existing applications; you will have to rebuild the
application(s), which defeats the purpose of having DLLs.
This project was created with Visual C++ 1.51.
If you have any questions or comments regarding this matter, call me at
502-262-9972, or e-mail me at JamesInKY@aol.com.
James Anderson
Technology Consulting
1800 Meidinger Tower
Louisville, KY 40202
(502) 589-3110