I fixed my prototype and made the first call succeed.
#include <windows.h> #include <iostream>
#include <gdiplusenums.h> #include <gdiplustypes.h>
#include <gdiplusgpstubs.h> #include <gdiplusmetaheader.h>
#include <gdipluspixelformats.h> #include <gdipluscolor.h> #include <gdipluscolormatrix.h> #include <gdiplusimaging.h> struct IDirectDrawSurface7; #include <gdiplusflat.h>
#pragma comment(lib,"gdiplus")
typedef GpStatus (WINGDIPAPI *pfnGdipEnumerateMetafileSrcRectDestRectI)( GpGraphics* graphics, GDIPCONST GpMetafile* metafile, GDIPCONST Rect* destRect, GDIPCONST Rect* srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID* callbackData, GDIPCONST GpImageAttributes* imageAttributes );
int main() {
Rect s{}, d{}; auto m = LoadLibraryA("gdiplus.dll"); pfnGdipEnumerateMetafileSrcRectDestRectI pfunc = (pfnGdipEnumerateMetafileSrcRectDestRectI)GetProcAddress(m, "GdipEnumerateMetafileSrcRectDestRectI"); __try { pfunc(0, 0, &s, &d, UnitDisplay, 0, 0, 0); printf("ok\n"); pfunc(0, 0, 0, 0, UnitDisplay, 0, 0, 0); printf("ok\n"); } __except (EXCEPTION_EXECUTE_HANDLER) { printf("Executing SEH __except block\r\n"); } system("pause"); }
And the result is printed as below :
ok Executing SEH __except block
Thanks.