Stencil
Stencil

Reputation: 1873

Windows GDI Context - Function fails and GetLastError() returns 0

Is it possible for a Windows API function to fail, and then, just after it, GetLastError() return 0? I don't think that showing some code or not really matters: in which cases does it happen?

if ( !(hbmp = (HBITMAP) LoadImage(hThisInstance, MAKEINTRESOURCE(IMG), 
       IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION)))
    printf("Last error: %d\n", GetLastError());

With: HBITMAP hbmp HINSTANCE hThisInstance IMG bitmap resource

Upvotes: 1

Views: 886

Answers (1)

Stencil
Stencil

Reputation: 1873

I found the problem to reside in my bitmap image 32 bits encoding. LoadImage() fails without setting an error code while trying to load it, though. I definitely think it should be considered as a error handling inaccuracy within LoadImage() itself, notwithstanding any warning about such constraints possibly claimed in online documentation.

Upvotes: 1

Related Questions