调用FreeLibrary后使用HBITMAP是否有效?

发布于 2024-08-25 08:17:28 字数 306 浏览 1 评论 0原文

我有一个情况,我需要从资源 dll 加载位图并释放它的句柄。更新机制可能会更新dll,打开它会无法覆盖它。

假设我有这样的事情:

HINSTANCE hInst = LoadLibraryEx(resourceDll, NULL, LOAD_LIBRARY_AS_DATAFILE);
HBITMAP hBitmap = LoadBitmap(hInst, "some.bmp")
FreeLibrary(hInst);

调用 FreeLibrary 后使用 hBitmap 是否有效?

提前致谢。

I have a case where I need to load bitmap from a resource dll and release handle to it. The update mechanism may update the dll, and having it open will fail overwriting it.

So lets say I have something like this:

HINSTANCE hInst = LoadLibraryEx(resourceDll, NULL, LOAD_LIBRARY_AS_DATAFILE);
HBITMAP hBitmap = LoadBitmap(hInst, "some.bmp")
FreeLibrary(hInst);

is it valid to use hBitmap after calling FreeLibrary ?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没有你 2024-09-01 08:17:28

是的,释放DLL是有效的。

LoadBitmap 的作用相当于 CreateCompatibleBitmap,它为您的进程创建一个新的位图。位图图像使用 DLL 资源中的数据进行初始化。即,将像素信息复制到位图中。位图不保存指向资源数据的指针。一旦创建,您就可以释放DLL。

Yes, it's valid to release the DLL.

LoadBitmap does the equivalent of CreateCompatibleBitmap, which creates a new bitmap for your process. The bitmap image is initialized with the data from the DLLs resource. That is, the pixel information is copied to the bitmap. The bitmap does not hold a pointer to the resource data. Once created, you can release the DLL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文