FindResource在VS2012中返回错误1813 [英] FindResource returns error 1813 in VS2012
本文介绍了FindResource在VS2012中返回错误1813的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 FindResource
查找资源,但它一直返回错误代码1813(未找到资源)。
资源在* .rc文件中定义为
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"
和我正在使用 FindResource(NULL,MAKEINTRESOURCE(IDR_RC_DATA1),MAKEINTRESOURCE(RC_DATA));
来查找资源。
推荐答案
FindResource()
的第三个参数定义资源类型,必须是此类型的名称,标准类型之一或ID由MAKINTRESOURCE()
转换的类型标识符。另请参阅 MSDN [ ^ 一>]。你可以使用其中一个:
The third parameter ofFindResource()
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 byMAKINTRESOURCE()
. 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));
MAKEINTRESOURCE("RC_DATA") // is wrong
// it should be
MAKEINTRESOURCE(RC_DATA) // without the quotes
这篇关于FindResource在VS2012中返回错误1813的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文