So I don’t know why I keep getting this error. Here’s the relevant code:
//////////////////////// In resource.h ///////////////////////////
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Freestyle.rc
//
#define IDB_BITMAP1 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//////////////////////// In the resource file ////////////////////
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
.
.
.
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP1 BITMAP "NOP.bmp"
//////////////////////// In DllMain: /////////////////////////////
// Save the global module we're attached to other files can access it.
g_hLocalModule = hModule;
UnsafePrintToLog(SIMPLE_FORMAT_STRING, "Starting session...");
// Display the splash screen.
CSplash splashScreen(IDB_BITMAP1);
//////////////In CSplash::CSplash(WORD resourceID) //////////////
BitmapSplash = LoadBitmap((HINSTANCE)g_hLocalModule, MAKEINTRESOURCE(resourceID));
if(BitmapSplash == NULL)
{
volatile int temp = GetLastError();
Exit("Could not load the splash screen bitmap.");
}
Is the bitmap resource you’re trying to load in the DLL, or in the application that loaded the DLL?
When loading resources in a DLL, there are two possible sources, which is why the hInstance parameter is crucial.
Using the HINSTANCE parameter that you get from DllMain means that the resource is part of your DLL.
If the resource is located in the application that loaded your DLL, you can pass NULL in as the first argument of LoadResource(), and the application’s resources will be searched.
From the documentation for LoadResource:
Hope that helps.
-Scott