The development tool installation directory contains the include and Lib directories, which store the API declarations provided by the OS and encapsulated classes for convenience.ProgramMost of the services provided by encapsulated classes are implemented by calling the OS APIs, but the actual OS APIs are implemented in one DLL. When we want to use these Apis or encapsulated class services, the general practice is as follows:
// Test. cpp
# Include <XXX. h>
# Param comment (Lib, "XXX. lib ")
// Call an API or use an encapsulated class
The program developed using the above method cannot work normally in any system, because when executing this program, the system dynamically loads the various DLL used by the system, these DLL Programs depend on may not always exist in the system, such as gdiplus. DLL does not exist in 2000 by default. When loading fails, the program may be faulty.
A solution is to include the DLL that the program depends on in the installation package of the program, but this will increase the installation package.
Another solution is: if you can allow the loss of some APIs provided by the DLL, you can consider the solution described below.
(1) Remove # Param comment (Lib, "XXX. lib ")
(2) encapsulate APIs
Suppose you use void apifunc1 (); then you provide a void apifunc1 (); Function
The function is implemented as follows:
Void apifunc1 ()
{
Loadlibrary ("XXX. dll ");
If loading fails, or a simplified version is directly returned or implemented by yourself;
If the load is successful, call the real API
}
(3) Some methods provided by some encapsulated classes provided by the development tool call the API directly, and we also change this method. However, most of these encapsulated classes are in the include directory, and the files in this directory cannot be changed at will. What should we do? We only need to follow the 2 method. When the compiler links the API, it links our own program because it finds that the function is implemented in our program.