简体   繁体   中英

How to generate resource entry of string type ID?

I have a .rc file with the following entry:

01111 my_res { "string 1" }
01113 my_res { "string 2" }
01119 my_res { "string 3" }

When I compile this .rc file with rc.exe, the resource entry id become 1111 , 1113 and 1119 respectively.

Apparently, the resource compiler treated the ID as numerics.

My first impression was the .res files can't store numeric as string type. But when use a resource editor (eg: XNResourceEditor.exe to change the resource ID 1111 to 01111 and it stored as 01111 . This shows that the resource id may store numeric as string type.

Is there a way to compile numeric resource id as string type?

The resource compiler RC does not have any syntax that allows you to escape an integer ID so that it is treated as text.

The documentation says:

Unique name or a 16-bit unsigned integer that identifies the resource.

The resource compiler attempts to interpret the ID as an integer. If it can do so then the ID is interpreted as an integer, otherwise it is interpreted as a string. If the integer exceeds the bounds of a 16 bit integer, then its value and 0xffff is used.

This is a limitation of the resource compiler. The resource format supports text IDs that only contain digits. If it is crucial for you to produce such resources then I think you would need to either:

  1. Find a resource compiler that does allow numbers to be escaped as text, or
  2. Write your own basic resource compiler to perform the task.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM