Click here to Skip to main content
15,667,281 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
IDR_RC_DATA1            RC_DATA                 "C:\\...\\test.txt"

and am using FindResource(NULL, MAKEINTRESOURCE(IDR_RC_DATA1), MAKEINTRESOURCE("RC_DATA")); to find the resource.
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
// Pass type by standard type (IDR_RC_DATA1 must be of this type)
// Pass type by ID (type ID must be defined in resource.h or somewhere else)
Share this answer
Oso Oluwafemi Ebenezer 21-May-13 6:38am    
Thank you so much FindResource(NULL, MAKEINTRESOURCE(IDR_RC_DATA1), _T("RC_DATA")); did the magic
// it should be
MAKEINTRESOURCE(RC_DATA) // without the quotes
Share this answer
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