Question:
For A.dll, B.dll, C.dll and even the app, can they call for their own
GdiplusStartup() to obtain their own tokens, and call their own
GdiplusShutdown(), without interfering the gdi+ objs in other dlls?
Reason:
For some dlls I develop, they will be loaded (using AfxLoadLibrary) only
when they are demanded. Therefore if the case described in the question can
work, then I do not need to concern about whether some gdi+ objs will be
invalidated because GdiplusShutdown() is being called somewhere else when
that dll is unloaded.
It doesn't say that they can be called multiple times, but seeing as it
returns a token that you have to explicitly shutdown, it implies that
you can.
Normally, Init/Cleanup functions that don't use a token explicitly say
they are reference counted and can be called multiple times.
GdiplusShutdown says "Each call to GdiplusStartup should be paired with
a call to GdiplusShutdown." again implying that you can have multiple
tokens.
--
Dee Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
iCode Systems
"Dee Earley" wrote:
> .
>
I looked at the following article from MS:
http://support.microsoft.com/default.aspx/kb/322909
and there is a paragraph, as quoted:
This problem occurs because the CImage class initializes and then shuts down
GDI+ by using the static nested class CInitGDIPlus. This class initializes
GDI+ before any CImage function that requires GDI+ is called. GDI+ is shut
down by calling GdiplusShutdown when the CInitGDIPlus class is destructed.
CInitGDIPlus is a static class that is destructed in a DLL in the context of
DllMain. The documentation states that you cannot call GdiplusShutdown in
DllMain.
As far as I interpret it right, multiple callings of GdiplusStartup() is
allowed, but the corresponding calls of GdiplusShutdown() must be nested. If
that is true, this will be a big trouble for my scenario, because I cannot
control the order of dll-release, even explicitly calling an exported
dll-release function.
For some developers, they experienced app hanging after calling
GdiplusShutdown().
Is GDI+ that horrible?
Yes. We also sometimes experience these problems with our add-on
DLLs. You mght consider to ONCE load and initialize GDIPLUS and leave
shutdown to the process cleanup of the OS.
Christian