1. dll Concept
The dynamic link library (DLL) is short for dynamic link library. dll is a library that contains code and data that can be used by multiple programs at the same time. dll is not an executable file. Dynamic links provide a way for a process to call a function that does not belong to its executable code. The executable code of a function is located in a DLL, which contains one or more functions that have been compiled, linked, and stored separately from the processes that use them. DLL also helps to share data and resources. Multiple applications can simultaneously access the content of a single DLL copy in the memory. DLL is a library that contains code and data that can be used by multiple programs at the same time.
2. dll advantages
A. extends the features of applications;
B. It can be written in many programming languages;
C. simplified the management of software projects;
D. It helps to save memory;
E. Facilitates resource sharing;
F. Facilitates application localization;
G. helps resolve platform differences;
H. It can be used for some special purposes. Windows allows some features to be used only by DLL.
3. Create DLL
Create a DLL project,
Add the tested helloworld function to the Project
Extern "C" _ declspec (dllexport) bool helloworld () <br/>{< br/> MessageBox (null, _ T ("This Is The dll library interface"), null, 0); <br/> return true; <br/>}
After compilation, the DLL. lib and DLL. DLL files are generated.
4. dll call Method
Create an MFC project and add the test button on the interface. Before calling the API, you must declare the name of the referenced External Database and the external function interface. The description and specific implementation Code are as follows:
# Pragma comment (Lib, "DLL. lib ") // reference External library <br/> extern" C "_ declspec (dllimport) bool helloworld (); // declare the call interface <br/> void cdllmfcdlg :: onbnclickedbutton1 () <br/>{< br/> helloworld (); <br/>}< br/>