FindResource function

Determines the location of a resource with the specified type and name in the specified module.

To specify a language, use the FindResourceEx function.

根据指定的类型和名字来确定资源文件的地址。

如果需要指定语言,请使用函数FindResourceEx。

Syntax

C++
HRSRC WINAPI FindResource(
  _In_opt_  HMODULE hModule,
  _In_      LPCTSTR lpName,
  _In_      LPCTSTR lpType
);

Parameters

参数

hModule [in, optional]( 可选

Type: HMODULE

A handle to the module whose portable executable file or an accompanying MUI file contains the resource. If this parameter is NULL, the function searches the module used to create the current process.

第一个参数:包含了资源的可执行文件或附随的MUI文件所属的 Module的句柄。        如果这个参数是NULL, 这个函数搜索module去创建当前的线程。(不懂!)

lpName [in]

Type: LPCTSTR

The name of the resource. Alternately, rather than a pointer, this parameter can be MAKEINTRESOURCE(ID), where ID is the integer identifier of the resource. For more information, see the Remarks section below.

第二个参数:资源文件的名字。这个参数是一个MAKEINTRESOURCE(ID)(资源文件的ID),而不是一个指针。(不懂!)

lpType [in]

Type: LPCTSTR

The resource type. Alternately, rather than a pointer, this parameter can be MAKEINTRESOURCE(ID), where ID is the integer identifier of the given resource type. For standard resource types, see Resource Types. For more information, see the Remarks section below.

第三个参数:资源文件的类型。。。。

Return value

返回值

Type: HRSRC

If the function succeeds, the return value is a handle to the specified resource's information block. To obtain a handle to the resource, pass this handle to the LoadResource function.

如果函数执行成功 ,返回值是指定资源文件信息内存的句柄。如要获取资源文件的句柄,将这个句柄传递给函数LoadResource

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

如果函数执行失败,返回值为NULL. 。。。。

Remarks

备注

If IS_INTRESOURCE is TRUE for x = lpName or lpType, x specifies the integer identifier of the name or type of the given resource. Otherwise, those parameters are long pointers to null-terminated strings. If the first character of the string is a pound sign (#), the remaining characters represent a decimal number that specifies the integer identifier of the resource's name or type. For example, the string "#258" represents the integer identifier 258.

假如用x 表示 lpName 或者 lpType,当IS_INTRESOURCE为TRUE,x表示给定资源文件的类型或者名字的ID(整型)。否则,这些参数是指向以null结束的字符串的指针(long型)。如果字符串的第一个字符是井号(#),则后面的字符表示一个十进制数字(此数字就是资源文件名字或类型的整型ID)。比如字符串“#258”表示整型ID258.

To reduce the amount of memory required for a resource, an application should refer to it by integer identifier instead of by name.

为了减少资源文件内存的数量,应用程序应该通过整型ID而不是名字去查阅这个资源文件。(也就是要把IS_INTRESOURCE设为TRUE?)

An application can use FindResource to find any type of resource, but this function should be used only if the application must access the binary resource data by making subsequent calls to LoadResource and then to LockResource.

应用程序可以使用函数FindResource来查找任何类型的资源文件,但是只有在应用程序先后调用了函数LoadResource 和函数LockResource之后,且必须以二进制数据的格式进行存取的条件下才能使用这个函数。

To use a resource immediately, an application should use one of the following resource-specific functions to find the resource and convert the data into a more usable form.

如果要立即使用资源文件,应用程序使用如下的函数去查找资源文件和转换成可用的数据格式。

FunctionAction
FormatMessageLoads and formats a message-table entry.
LoadAcceleratorsLoads an accelerator table.
LoadBitmapLoads a bitmap resource.
LoadCursorLoads a cursor resource.
LoadIconLoads an icon resource.
LoadMenuLoads a menu resource.
LoadStringLoads a string-table entry.

 

For example, an application can use the LoadIcon function to load an icon for display on the screen. However, the application should use FindResource and LoadResource if it is loading the icon to copy its data to another application.

比如,应用程序可以使用函数LoadIcon在屏幕上加载图像进行显示。尽管如此,如果正在加载图标以复制其数据给其他应用程序,那么应用程序同时应该使用函数FindResource 和函数 LoadResource

String resources are stored in sections of up to 16 strings per section. The strings in each section are stored as a sequence of counted (not necessarily null-terminated) Unicode strings. The LoadString function will extract the string resource from its corresponding section.

字符串资源文件被存储在最多可以存放16个字符串的section里面。在每个section里面的字符串是以顺序存储的Unicode(不需要以nll作为结束符)。LoadString函数能从相应的section里面提取出字符串源。

Examples

For an example, see Updating Resources.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

FindResourceW (Unicode) and FindResourceA (ANSI)

See also

Reference FindResourceEx IS_INTRESOURCE LoadAccelerators LoadCursor LoadIcon LoadMenu LoadResource LoadString LockResource SizeofResource Conceptual Resources Other Resources FormatMessage LoadBitmap

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值