Here I borrow some of the content from the website and add some of my interpretation.
The essential part to generate a usable dll file is the modification of the header file from the original one for exe file.
For example, the hello.h should be
// hello.h___________________
#ifdef __cpluscplus
#define EXPORT extern "C" __declspec(dllexport)
#else
#define EXPORT __declspec(dllexport)
#endif
EXPORT void hello();
// end hello.h___________________
In the main file, hello.c, we can simply keep the original file as the original one, such as
// hello.c___________________
#include"hello.h"
#include
EXPORT void hello(){
printf("The First Hello World !");
}
- To build a hello.dll, in visual C++ 6, we can create a dll project with the inclusion of the files above.
- To use the hello.dll, we should include the hello.lib generated from the compiler into the main executable code. Then the dll, lib and other codes are put in the same folder to make a new executable file which can use the functions in dll files.
No comments:
Post a Comment