The project needs to be changed some time ago. Therefore, I changed some of the project's GDI to GDI +, mainly to increase the support for image formats, so I have no time to read things, because I used to be familiar with GDI +, I used it directly. Add gdiplusstartup and gdiplusshutdown of gdiplus to the dllmain of several projects at the beginning. However, it is found that the registration output remains unchanged at the time of production and must be manually canceled. I haven't encountered any major problems in use, so I will temporarily leave it there. Today's work is coming to an end. Let's analyze this problem. First, it was identified as caused by gdiplus, and then searched for a lot of information. It was found that there was a problem with the initialization of GDI +. In the DLL project, You Cannot initialize the GDI + in the dllmain file. See http://msdn.microsoft.com/en-us/library/ms534077 (vs.85). aspx Remarks
You must call gdiplusstartup before you create any GDI + objects, and you must delete all of your GDI + objects (or have them go out of scope) before you call gdiplusshutdown.
You can call gdiplusstartup on one thread and call gdiplusshutdown on another thread as long as you delete all of your GDI + objects (or have them go out of scope) before you call gdiplusshutdown.
Do not call gdiplusstartup or gdiplusshutdown in dllmain or in any function that is called by dllmain. if you want to create a DLL that uses GDI +, you should use one of the following techniques to initialize GDI +:
Require your clients to call gdiplusstartup before they call the functions in your DLL and to call gdiplusshutdown when they have finished using your DLL.
Export your own startup function that CILS gdiplusstartup and your own shutdown function that CILS gdiplusshutdown. require your clients to call your startup function before they call other functions in your DLL and to call your shutdown function when they Have finished using your DLL.
Call gdiplusstartup and gdiplusshutdown in each of your functions that make GDI + CILS. |