Routine detail dynamic link library

zhaozj2021-02-16  95

Article Title: Dynamic Link Link Location: BULL77 Original: LOOSE_WENT Publishing Type: Reprint Release Date: 2004-05-08 Today Views: 11 Total View: 1468

Dynamic Link Library (DLL, ie Dynamic-Link Library is an executable module, but it does not have its own stack, you must run in the program environment that calls the dynamic link library function. Dynamic Link Library can not only be used as a run module, including function code, but also any data or resource (bitmap, icon, etc.) other than the program. The dynamic link library is to provide functions or resources to the application. Dynamic links and static links are relatively vertical. When static links, the executable program contains the code accessed, and the user occupies a large space; but when running, there is no need for other modules to support, so that the speed is relatively fast. Dynamic linking executable does not include dynamically access function code, only contains support for its reference, and other modules (DLLs) are required, and the speed is relatively slow. The dynamic link library is an extremely important technology for Windows. It enables developers to develop dynamic link libraries to facilitate the development of large programs, expand the operating system by their own wishes. The following example describes how to define functions, resources, and classes in the dynamic link library, and how to use the function, resources, classes defined in the dynamic link library in the project. I. Definition and use of functions: Step 1: Run AppWizard, define the project name MyDLL, select the MFC AppWizard (DLL) instead of MFC AppWizards (Exe). Step 2: In this example, only one appWizard screen appears, select the MFC Extension DLL (MFC Extension DLL (MFC Extension DLL), click Finish generation project. Step 3: Click New in File, select C / C Header File, File Name Enter the DLL, click OK, create DLL.h. Enter Extern "C" __DECLSPEC (DLLEXPORT) INT FUN (INT X1, INT X2, INT X3);, save. Step 4: Click New in File. , Select C Source File, enter the DLL in File Name, click OK, create dll.cpp. Enter #include "stdafx.h" #include "dll.h" extern "c" __declspec (dllexport) int Fun (int x1, int tent X2, INT X3) {RETURN X1 X2 X3;} Compile Generate MyDLL.dll and MyDLL.LIB. Step 5: Select New in Add to Project in Project, regenerate a project, select MFC AppWizards (Exe), The project name is Mydlltest, select Single Document, click Finish to generate a new project. Select Project àset Active Project àmydlltest in the menu, set mydlltest to the current activity project. Step 6: Copy ... / mydll / debug / mydll.dll Under ../mydllte/debug/, copy ... / mydll / debug / mydll.lib to ... / mydlltest / directory.

转载请注明原文地址:https://www.9cbs.com/read-11163.html

New Post(0)