First to set out the DLL (Dynamic Linkable Library) concept, you can simply the DLL as a kind of warehouse, it offers you some of the variables can be used to use, function or class. History of the development in the warehouse through the "no library - static link library - Dynamic Link Library" era.
Static link library dynamic link library is shared with the way the code, if the static link library, whether you are willing, lib of the instructions are generated directly included in the final EXE file in the. However, if the use of DLL, the DLL not be included in the final EXE file, EXE file when the implementation of "dynamic" to quote and unload the DLL and EXE file independent. Static link library and the dynamic link library, another difference is that the static link library can not contain other dynamic-link library or static library, but also in the dynamic link library can be further contain other dynamic or static link library.
Dynamic link library, we must develop the following concepts:
(1) DLL's compiled with a specific programming language and compiler independent
Follow the convention of the DLL as long as the interface specification and the call mode, DLL written in various languages can call each other. For example, Windows provides a system DLL (which includes the Windows-API), in any development environment can be called, never mind its a Visual Basic, Visual C + + or Delphi.
(2) dynamic link library can be seen everywhere
We are in the Windows directory under the system32 folder to see kernel32.dll, user32.dll and gdi32.dll, windows most of the API are included in the DLL. kernel32.dll function in the main processing memory management and process scheduling; user32.dll function in the main control of the user interface; gdi32.dll in respect of the function is responsible for graphics operation.
Programmers are generally similar to MessageBox function used, in fact, that it is included in the dynamic link library user32.dll. This shows that DLL is not unfamiliar to us.
(3) VC classification of the dynamic link library
Visual C + + supports three DLL, namely the Non-MFC DLL (non-MFC dynamic libraries), MFC Regular DLL (MFC rules DLL), MFC Extension DLL (MFC extension DLL).
Non-MFC dynamic libraries do not use MFC class library structure, the export function for standard C interface, can be written in non-MFC or MFC application that calls; MFC rules DLL contains a class that inherits from CWinApp, but no message loop; MFC extension DLL using MFC to create a dynamic link version, it can only be prepared to use MFC class library calls the application.
As this lengthy, more content will definitely need to read this article on matters related note, the following questions and answers given in the form.
Q: What are the contents of this paper to explain?
A: This paper describes all aspects of DLL programming, to completion of this DLL should be able to have a more comprehensive grasp, and can write most of the DLL program.
Q: How do see this?
Answer: This explanation of each topic are included with the source code routine, with the text can be downloaded (each project by WINRAR compressed). All of these routines written by the author and debug by VC + +6.0.
Certainly not the readers understand the ultimate goal of this article, readers should be hands-on practice to really master the subtleties of DLL.
Q: What kind of learning this basic knowledge?
A: If you master C, and generally control the C + +, to understand that the knowledge of MFC, you can easily read this article.
2. Static Link Library
To explain the static link library is not the focus of this article, but the specific DLL before explaining, through the example of a static link library to help us quickly establish a "library" concept.
Figure 1, a static link library
Figure 1, in a VC + +6.0 in the new name for the libTest the static library project (click here to download the attachment in this project), and New lib.h and lib.cpp two files, lib.h and lib.cpp The source code is as follows:
/ / File: lib.h
# Ifndef LIB_H
# Define LIB_H
extern "C" int add (int x, int y); / / declared as a C compiler, the external connection function
/ / File: lib.cpp
# Include "lib.h"
int add (int x, int y)
return x + y;
Compile this project to get a. Lib file, this file is a library, add the functionality it provides. The header files and. Lib file to the user, the user can directly use one of the add function of the.
Standard Turbo C2.0 in the C library functions (we use the scanf, printf, memcpy, strcpy, etc.) came from such a static library.
Here take a look at how to use the library, where the work of the project in libTest a libCall new project area. libCall project contains only one main.cpp file, it shows a static link library for calling the method, its source code is as follows:
# Include ".. lib.h"
# Pragma comment (lib, ".. \ debug \ libTest.lib") / / specify the connection with the static library
int main (int argc, char * argv )
printf ("2 + 3 =% d", add (2, 3));
Static link library call is as simple as perhaps we use every day, but we do not understand the concept. Code # pragma comment (lib, ".. \ debug \ libTest.lib") means that in this paper generated. Obj file should be connected together with libTest.lib.
If you do not specify # pragma comment, you can set VC + +, as shown in Figure 2, choose tools, options, directories, library files menu or option, fill in the library path. Red circle in Figure 2 plus some added libTest.lib our path to the file.
Figure 2 is set in the VC library path
Examples of the static link library at least let us see how the library functions going on, they come from. We now have a vague understanding of the following:
(1) library is not a monster, the preparation of libraries of procedures and the preparation procedures generally little different, but libraries can not be executed;
(2) library provides to other procedures that can be called the East, another program to call it must be some way of specifying that it should be called.
From the above analysis of the static link library on the library get muddled concept can be extended to the dynamic link library, dynamic link libraries and static link library and call in the preparation of the different reflected in the library on the external interface definition and call a slightly different way .
3. The library and view the debugger
In specific detail into the various DLL's before, it is necessary to debug and view the library method look description, because the next section, we will be faced with a large number of examples of projects.
As the library file can not be executed, thus pressing F5 (start debug mode execution) or CTRL + F5 (run) the implementation of, its pop-up dialog box shown in Figure 3, requires users to enter the path of the executable file to start the library execution of the function. This time we enter the call the library path of EXE file can be debugged on the library, and its general application debugging skills and debug the same project.
Figure 3 library debugging and "Run"
The practice is usually better than debugging means that the library project and application engineering (call the library project) located in the same VC workspace, application engineering for debugging only, call the library at the application engineering function to set the statement Department breakpoint, execution, press F11, so step into the library function. Section 2 of the libTest and libCall project to put the same work area, the project structure shown in Figure 4.
Figure 4 library project and call the library project to debug into the same work area
The testing method and the static link library dynamic link library in terms of the same.鎵?互鏈枃鎻愪緵涓嬭浇鐨勬墍鏈夋簮浠ｇ爜涓兘鍖呭惈浜嗗簱宸ョ▼鍜岃皟鐢ㄥ簱鐨勫伐绋嬶紝杩欎簩鑰呴兘琚寘鍚湪涓?釜宸ヤ綔鍖哄唴锛岃繖鏄瑪鑰呮彁渚涜繖绉嶆墦鍖呬笅杞界殑鐢ㄦ剰鎵?湪銆?br />
銆??鍔ㄦ?閾炬帴搴撲腑鐨勫鍑烘帴鍙ｅ彲浠ヤ娇鐢╒isual C++鐨凞epends宸ュ叿杩涜鏌ョ湅锛岃鎴戜滑鐢―epends鎵撳紑绯荤粺鐩綍涓殑user32.dll锛岀湅鍒颁簡鍚э紵绾㈠湀鍐呯殑灏辨槸鍑犱釜鐗堟湰鐨凪essageBox浜嗭紒鍘熸潵瀹冪湡鐨勫湪杩欓噷鍟婏紝鍘熸潵瀹冨氨鍦ㄨ繖閲屽晩锛?br />
binkw32 dll is missing ERROR can it be fixed
Comment Puzzle And Word Games
"Tomato Garden" What end result?
MPG to 3GP
JSF And Struts Framework For Error Control And Package Handling
CSS SYNTAX Guide (4) text fill, borders, boundaries and location of the property (2)
Dealers should not be fishing in 10
ASF To MOV
Yuan Meng: Ubuntu 9.10 new version of the debut
Interview With Eastman Kodak Asia Pacific Director Of Human Resources Is Pleased To Ms.
Write a custom task, easily extend Ant
ping Command usage
Evaluate Project Management
Using Visual Basic's Timer CONTROL
Comment Audio CD Players