c++ - 访问位图资源失败,错误代码为 0x716

标签 c++ windows winapi resources

所以我不知道为什么我一直收到这个错误。这是相关代码:

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

最佳答案

您尝试加载的位图资源是在 DLL 中还是在加载 DLL 的应用程序中?

在 DLL 中加载资源时,有两种可能的来源,这就是 hInstance 参数至关重要的原因。

使用从 DllMain 获得的 HINSTANCE 参数意味着该资源是您的 DLL 的一部分。

如果资源位于加载您的 DLL 的 应用程序 中,您可以将 NULL 作为 LoadResource() 的第一个参数传入,应用程序的资源将是搜索过。

来自 LoadResource 的文档:

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

希望对您有所帮助。

-斯科特

关于c++ - 访问位图资源失败,错误代码为 0x716,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1183572/

相关文章:

C++14 元编程 : Automagically build a list of types at compile/init time

c++ - 处理无法按预期方式创建的对象,C++

使用 Win32 API 连接字符串

c++ - 如何向 Global char *Array[] 添加一个元素?

c++ - 尽管 namespace 正确,但重复出现错误

c - 如何从 Windows 命令提示符运行 C 程序?

.net - 如何从链接中删除空格

windows - 在 Windows 上读取原始 USB 输入

c++ - WSAEventSelect,一个事件,多个套接字

python - 从 Python 3 调用 Windows API 时句柄无效