Answer the question
In order to leave comments, you need to log in
How to get the hmodule of a resource?
In general, I'm trying to unload a jpg image from the resources of my program of my program, it is stored not in a dll, but in an exe.
Here is the code
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#include "resource.h"
using namespace std;
int main()
{
//hmodule
HRSRC jpg_resource = FindResource(NULL, (LPCWSTR)IDR_JPG1, L"JPG");
if (!jpg_resource)
{
DWORD err;
GetLastError();
}
cout << "HRSRC = " << jpg_resource << "\n";
HGLOBAL load_resource = LoadResource(NULL, jpg_resource);
if (!load_resource)
{
DWORD err;
GetLastError();
}
cout << "HGLOBAL = " << load_resource << "\n";
HANDLE load_image = LoadImage(NULL, L"from_exe.jpg", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if (!load_image)
{
DWORD err;
GetLastError();
}
cout << "HANDLE = " << load_image << "\n"; //всё время выводил 0
return 0;
}
Answer the question
In order to leave comments, you need to log in
I pulled from my old project calls to read the resource.
True, my resources were textual, but the essence of this does not change.
HMODULE hModule = GetModuleHandle(NULL);
HRSRC hResInfo = FindResourceA(hModule, MAKEINTRESOURCEA(IDR_README1), MAKEINTRESOURCEA(READMETXT));
HGLOBAL hResource = LoadResource(hModule, hResInfo);
DWORD nSize = SizeofResource(hModule, hResInfo);
LPVOID resource = LockResource(hResource);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question