How to load OBM_OLD_ xxx bitmaps

QuiesceJ 0 Reputation points
2025-10-12T15:45:12.4266667+00:00

Hello,

I need some help with the LoadBitmap() API function. I want to load Windows 3.x bitmaps, but I get error code 6 (INVALID_HANDLE). This doesn't happen with contemporary bitmaps (e.g., OBM_REDUCE). Here is the short code I am testing. In your opinion, what could be missing ?

#define OEMRESOURCE
#include <windows.h>
#include <stdio.h>

int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdline, int nCmdShow )
{
	char msg[50];

	// HBITMAP hbmp = LoadBitmap( NULL, (LPTSTR) OBM_REDUCE );	// OK
	HBITMAP hbmp = LoadBitmap( NULL, (LPTSTR) OBM_OLD_REDUCE );
	if( hbmp ) {
		sprintf( msg, "OK : hbmp = %p", hbmp );
		MessageBox( NULL, msg, "OBM", MB_OK );
	}
	else  {
		DWORD dw = GetLastError();
		sprintf( msg, "KO : %d, hbmp = %p", dw, hbmp );
	 	MessageBox( NULL, msg, "OBM", MB_OK );
	}
	return 0;
}

Thank you for your help.

Windows development | Windows API - Win32
0 comments No comments
{count} votes

Answer recommended by moderator
  1. Danny Nguyen (WICLOUD CORPORATION) 3,520 Reputation points Microsoft External Staff
    2025-10-13T04:25:05.2633333+00:00

    Hi @QuiesceJ ,

    Thank you for posting in Microsoft Q&A Forum.

    The OBM_OLD_* bitmaps (like OBM_OLD_REDUCE) were used in very early versions of Windows (16-bit Windows 2.x and 3.0). They were built into USER.EXE and represented the old system button graphics.

    Starting with Win32 (Windows NT and Windows 95), those legacy bitmaps were removed and replaced by the newer OBM_* versions (e.g. OBM_REDUCE, OBM_CLOSE, etc.). The “OLD” variants are no longer embedded in user32.dll, so LoadBitmap(NULL, MAKEINTRESOURCE(OBM_OLD_REDUCE)) will fail and return error 6 (ERROR_INVALID_HANDLE).

    There’s nothing missing in your code — the resource simply doesn’t exist anymore.

    If you want a similar bitmap, you can:

    • Use OBM_REDUCE (modern replacement), or
    • Include your own .bmp resource and load it with LoadImage() or LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MYBITMAP)).

    I hope this helps. Feel free to reach out if you need any clarification.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Castorix31 91,196 Reputation points
    2025-10-12T18:08:51.3566667+00:00

    OBM_* bitmaps are created dynamically from an internal array (in PERUSERSERVERINFO structure), but OBM_OLD_* bitmaps have been removed from this array


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.