|
For static connection, as long as .lib, no dll
There is also no .lib and .dll at runtime
There are two ways for dynamic connection
1. When compiling, you need .lib and the corresponding header file that contains the function declaration; you don't need .lib at runtime, but use .dll
2. If the dll is used in the program according to the addressing mode, it is required that the function name should be declared in the .def file when the dll is created. In this way, the .lib and .h files are not needed
Examples of addressing modes
LONG lResult;
HINSTANCE hModule;
// Create a new function pointer data type
typedef LONG (MULTIPLY2LONGSPROC) (LONG, LONG);
MULTIPLY2LONGSPROC * pfuncMultiply2Longs = 0;
// Import the file DYNLINK1.DLL, the file should be in the same directory as the EXE file or in the WINDOWS\SYSTEM\directory
VERIFY (hModule = :: LoadLibrary ("DYNLINK1.dll"));
// Get the address of the function Multiply2Longs () in the DLL
VERIFY (
pfuncMultiply2Longs =
(MULTIPLY2LONGSPROC *) :: GetProcAddress (
(HMODULE) hModule, "Multiply2Longs")
); |
|