views:

251

answers:

2

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.");
}
A: 

Error 0x716 means:

ERROR_RESOURCE_NAME_NOT_FOUND 1814 (0x716)

The specified resource name cannot be found in the image file.

Are you passing in to LoadBitmap the correct first parameter?

hInstance
[in] Handle to the instance of the module for which the executable file contains the bitmap that you want to load.

Is the resource file being compiled to a .res file and being included in the final executable?

Brian R. Bondy
1. I pass into LoadBitmap the hInstance parameter given to me by DllMain.2. Yes. It compiles fine. I can tell because I also have version information linked in, and it displays fine.3. That is answered if you read the code.
Clark Gaebel
Just before the call to LoadBitmap can you confirm that g_hLocalModule has the same value as was loaded in from the Dll?
Brian R. Bondy
Yes, I already have.
Clark Gaebel
+1  A: 

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:

If hModule is NULL, the system loads the resource from the module that was used to create the current process.

Hope that helps.

-Scott

Scott Smith