Win32 API Noobie - Custom resource not found, error 1812
Posted on 2004-08-01
I'm a beginning Win32 API programmer trying to get to grips with some of Petzold's examples.
The example here is the PoePoem program that illustrates use of Custom Resources. The custom resource is an external text file, PoePoem.txt, in ASCII.
The .RC Script has the following entry...
ANNABELLEE TEXT DISCARDABLE "PoePoem.txt"
The RESOURCE.H header file has this entry...
#define ANNABELLEE 102
When I load the compiled exe into a hex editor I can see the text is included in the file, so I know the resource is 'on board'.
However, when I try to load the resource...
hResource = LoadResource (hInst, FindResource (hInst, TEXT("ANNABELLEE"),TEXT ("TEXT"))) ;
...I get Error 1812 "The Specified Image File did not contain a resource section". Having isolated the FindResource statement I am sure that it is returning a null pointer, so it either doesn't like the ANNABELLEE reference, or it doesn't like the custom TEXT reference.
If I try to get cute with it and force it to use 102...
hResource = LoadResource (hInst, FindResource (hInst, TEXT("#102"),TEXT ("TEXT"))) ;
... I get Error 183, "Cannot create a file when that file already exists", which is odd if I'm trying to get a handle to a resource.
I'm using Visual Studio 6, on Windows 2000.
Your help would be appreciated.