User-Defined Resource

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

A user-defined resource-definition statement specifies a resource that contains application-specific data. The data can have any format and can be defined either as the content of a file or as a series of numbers and strings.

        nameID
        typeID
        filename
      

The filename specifies the name of a file containing the binary data of the resource. The contents of the file are included as the resource. The Resource Compiler (RC) does not interpret the binary data in any way. It is your responsibility to ensure that the data is properly aligned for the target computer architecture.

A user-defined resource can also be defined completely in the resource script using the following syntax.

        nameID
        typeID  { raw-data }

Parameters

  • nameID
    Specifies either a unique name or a 16-bit unsigned integer that identifies the resource.
  • typeID
    Specifies either a unique name or a 16-bit unsigned integer that identifies the resource type. If a number is specified, it must be greater than 255. The numbers 1 through 255 are reserved for existing and future redefined resource types.
  • filename
    Specifies the name of the file that contains the resource data. The parameter must be a valid file name, and it must be a full path if the file is not in the current working directory.
  • raw-data
    Specifies raw data consisting of one or more integers or strings of characters. Integers can be specified in decimal, octal, or hexadecimal format. To be compatible with 16-bit Windows, integers are stored as WORD values. You can store an integer as a DWORD value by qualifying the integer with the L suffix.

    Strings are enclosed in quotation marks. The Resource Compiler (RC) does not automatically append a terminating null character to a string. Each string is a sequence of the specified ANSI characters, unless you qualify it as a wide-character string with the L prefix.

    The block of data begins on a DWORD boundary and RC performs no padding or alignment of data within the raw-data block. It is your responsibility to ensure the proper alignment of data within the block.

Example

The following code example shows several user-defined statements.

array MYRES data.res
14 300 custom.res
18 MYRES2
{
  "Here is an ANSI string\0", // explicitly null-terminated 
  L"Here is a Unicode string\0", // explicitly null-terminated 
  1024, // integer, stored as WORD 
  7L, // integer, stored as DWORD 
  0x029a, // hex integer 
  0o733, // octal integer 
}