I am trying to add a text file to exe.... FindResource is always producing NULL, though..
my resource.h
#define nameID 101
#define typeID 256
my resource.rc
nameID typeID "Films20.txt"
in main()
HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(nameID), MAKEINTRESOURCE(typeID));
DWORD dwLastError = ::GetLastError();
cout << dwLastError << endl;
produces error: 1812.
ERROR_RESOURCE_DATA_NOT_FOUND
1812 (0x714)
The specified image file did not contain a resource section.
But I have a text file... "Films20.txt" which is in current project directory. I have also
tested with a full path... But it have also failed.
One more question:
First parameter (a handle) to FindResource is NULL ...
According to MS " .... If this parameter is NULL,
the function searches the module used to create the current process."
I have assumed that CodeBlocks will provide the handle to FindResource,
is it true?
I have the following compiler settings:
C compiler: x86_64-w64-mingw32-gcc.exe
C++ compiler: x86_64-w64-mingw32-g++.exe
Linker for dynamic libs: x86_64-w64-mingw32-g++.exe
Linker for static libs : x86_64-w64-mingw32-ar.exe
Resource compiler: x86_64-w64-mingw32-windres.exe
Make program: mingw32-make.exe
This is the build log
x86_64-w64-mingw32-windres.exe -J rc -O coff -i
C:\_C__~1\PROJECTS\RESOUR~1\resource.rc -o obj\Debug\resource.res
Execution of 'x86_64-w64-mingw32-windres.exe -J rc -O coff -i
C:\_C__~1\PROJECTS\RESOUR~1\resource.rc -o obj\Debug\resource.res' in 'C:\_C++\PROJECTS\Resources' failed.
Another question - in Build Targets should resource.h and resource.rc be checked along with the main.cpp ?
UPDATE - solved. the entry for the resource compiler has been wrong. There is no x86_64-w64-mingw32-windres.exe in MinGW/bin, just windres.exe.....