To create a DLL, you must first create one or more source code files, and there is a connection file to export functions. If you plan to use a DLL when you are loaded, you must also create an import library.
Create a source file
The Source code of the DLL contains functions and data to be exported, as well as internal functions and data, and there can be an optional portfolio. You can create a DLL using any support to create a Windows-based DLL tool.
If your DLL needs to support multi-thread, you should let your DLL do "thread security". You have to sync all the global data of DLL to avoid conflicts, but also to confirm that the library you use is just threads. For example, Microsoft® Visual C ® contains multiple C runtime libraries, one of which is not a thread, and the other two are threads.
Exit function
How to specify the export function is related to the development tool, some compilers allow using a modifier when declaring the exit function, and for others, you must specify an outlet declaration file when connecting.
For example, in Visual C , there are two ways to export the DLL function: _DECLSPEC modifier or a .def file. If the _declspec modifier is specified, it is not necessary to declare the .def file.
For more information on the export function, please refer to the relevant documentation of the development tool.
Create an import library
The import library (.lib) contains reference information for the exit function required for the connection program. By this information, the system can locate the desired DLL and DLL outlet functions at runtime.
E.g,
Be called
CreateWindow
The function will be imported into the user32.lib library when it is connected, because the CreateWindow function is in the User32.dll system DLL file, user32.lib is used to parse the code to the user32.lib exit function call. After the DLL is loaded, the function in the DLL needs to be corrected. Once the system initializer, since the exit function in the DLL is required, the user32.dll will be loaded, and then the function address table entry will be updated, and all CREATEWINDOW will turn The exit function in user32.dll is requested.
For more information on creating a warehouse, please refer to the relevant documentation of the development tool.
WARNING DLL calls the EXIXTPROCESS function will be an unpredictable program or system error. When you call EXITPROCESS from DLL, you need to confirm that you do know which program or system component will load this DLL, and call in the context is safe.