Click here to Skip to main content
15,881,742 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am trying to find a resource with FindResource but it kept returning error code 1813 (Resource not found).

The resource is defined in the *.rc file as
C++
IDR_RC_DATA1            RC_DATA                 "C:\\...\\test.txt"


and am using FindResource(NULL, MAKEINTRESOURCE(IDR_RC_DATA1), MAKEINTRESOURCE("RC_DATA")); to find the resource.
Posted
Comments
Volynsky Alex 21-May-13 5:01am    
Are you really sure that the IDR_RC_DATA1 string is present in your Resource.h ?
Oso Oluwafemi Ebenezer 21-May-13 5:17am    
Yes am very sure!
Oso Oluwafemi Ebenezer 21-May-13 5:21am    
#define IDR_RC_DATA1 101 in the resource.h file

The third parameter of FindResource() defines the resource type and must be the name of such a type, one of the standard types, or the ID of the type identifier converted by MAKINTRESOURCE(). See also in the MSDN[^]. Sou you may use one of these:
// Pass type by name
::FindResource(NULL, MAKEINTRESOURCE(IDR_RC_DATA1), _T("RC_DATA"));
// Pass type by standard type (IDR_RC_DATA1 must be of this type)
::FindResource(NULL, MAKEINTRESOURCE(IDR_RC_DATA1), RT_RCDATA);
// Pass type by ID (type ID must be defined in resource.h or somewhere else)
::FindResource(NULL, MAKEINTRESOURCE(IDR_RC_DATA1), MAKEINTRESOURCE(RC_DATA));
 
Share this answer
 
Comments
Oso Oluwafemi Ebenezer 21-May-13 6:38am    
Thank you so much FindResource(NULL, MAKEINTRESOURCE(IDR_RC_DATA1), _T("RC_DATA")); did the magic
C++
MAKEINTRESOURCE("RC_DATA") // is wrong
// it should be
MAKEINTRESOURCE(RC_DATA) // without the quotes
 
Share this answer
 
Comments
Oso Oluwafemi Ebenezer 21-May-13 5:24am    
Tried it before but the compiler outputted error C2065: 'RC_DATA' : undeclared identifier... This means RC_DATA is not recognized!
Richard MacCutchan 21-May-13 8:44am    
It should be RCDATA; no underscore, in the resource file. And RT_RCDATA in your source code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900