What am I doing wrong? Program crashes. [GDI+, WINAPI, C++]
<p>I wrote a program in C++ which has to print an image on the screen and exit after 2 seconds. Everything was ok until the program has to exit. When the program is on return 0; instruction, it crashes. I think it's because of wrong dealocation, but code seems to be correct.</p>

<hr>

<p><code></p>

<pre><code>#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;gdiplus.h&gt;

using namespace std;
using namespace Gdiplus;

HDC hdc = GetDC(NULL);

int main() {
    GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR           gdiplusToken;
    GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL);

    Graphics graphics(hdc);
    Rect dst(500, 500, 17, 17);
    Image* image = Image::FromFile(L"image.png", false);
    cout&lt;&lt;"Image size: "&lt;&lt;image-&gt;GetWidth()&lt;&lt;", "&lt;&lt;image-&gt;GetHeight()&lt;&lt;endl;
    graphics.DrawImage(image, dst);
    delete image;

    GdiplusShutdown(gdiplusToken);
    Sleep(2000);
    return 0;
}
</code></pre>

<p></code></p>

<hr>

<p>I've got the newest compilator and I compile by:</p>

<p>g++ -c main.cpp -std=g++11</p>

<p>g++ -o main main.o -lgdiplus</p>