The FindResourceEx
function is an extension of the FindResource
function in that it allows you to specify a particular language fork in which to search for the resource. Calilng the FindResource
function is equivalent to calling FindResourceEx
and passing zero as the wLanguage
.
Except for the horrible nasty gotcha: The second and third parameters to FindResourceEx
are in the opposite order compared to the second and third parameters to FindResource
!
In other words, if you are adding custom language support to a program, you cannot just stick a wLanguage
parameter on the end when you switch from FindResource
to FindResourceEx
. You also have to flip the second and third parameters.
Original code | FindResource(hModule, MAKEINTRESOURCE(IDB_MYBITMAP), RT_BITMAP) |
You change it to | FindResourceEx(hModule, MAKEINTRESOURCE(IDB_MYBITMAP), RT_BITMAP, 0) |
You should have changed it to | FindResourceEx(hModule, RT_BITMAP, MAKEINTRESOURCE(IDB_MYBITMAP), 0) |
The nasty part of this is that since the second and third parameters are the same type, the compiler won’t notice that you got them backward. The only way you find out is that your resource code suddenly stopped working.
0 comments