Reputation: 21
I tried to tested out a simple GDI+ program but could not initialize it. The GdiplusStartup returns 2 which means "invalid parameters". In debug mode, I can see GdiplusStartupInput startInput is initialized (GdiplusVersion=1 ....etc.) so it is not the problem.
#include <windows.h>
#include "resource.h"
#include <iostream>
#include <string>
#include <sstream>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
BOOL CALLBACK DialogProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
.... some code here ....
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
GdiplusStartupInput startInput;
ULONG_PTR* gdiToken = 0;
Gdiplus::Status status = Gdiplus::GdiplusStartup(gdiToken, &startInput, NULL);
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
}
Thanks
Upvotes: 0
Views: 1045
Reputation: 612934
The first argument is wrong. The documentation describes it like this:
Pointer to a ULONG_PTR that receives a token.
But you are passing a null pointer. Change the code like so:
GdiplusStartupInput startInput; // use default constructor to initialize struct
ULONG_PTR gdiToken;
Gdiplus::Status status = Gdiplus::GdiplusStartup(&gdiToken, &startInput, NULL);
Upvotes: 3