简体   繁体   English

如何生成字符串类型ID的资源条目?

[英]How to generate resource entry of string type ID?

I have a .rc file with the following entry: 我有一个带有以下条目的.rc文件:

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. 当我编译与RC.EXE这个rc文件,资源条目号成为111111131119分别。

Apparently, the resource compiler treated the ID as numerics. 显然,资源编译器将ID视为数字。

My first impression was the .res files can't store numeric as string type. 我的第一印象是.res文件无法将数字存储为字符串类型。 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. 但是当使用资源编辑器时(例如: XNResourceEditor.exe将资源ID 1111更改为01111并将其存储为01111这表明资源ID可以将数字存储为字符串类型。

Is there a way to compile numeric resource id as string type? 有没有办法将数字资源ID编译为字符串类型?

The resource compiler RC does not have any syntax that allows you to escape an integer ID so that it is treated as text. 资源编译器RC没有任何允许您转义整数ID的语法,因此它被视为文本。

The documentation says: 文件说:

Unique name or a 16-bit unsigned integer that identifies the resource. 唯一名称或标识资源的16位无符号整数。

The resource compiler attempts to interpret the ID as an integer. 资源编译器尝试将ID解释为整数。 If it can do so then the ID is interpreted as an integer, otherwise it is interpreted as a string. 如果它可以这样做,那么ID被解释为整数,否则它被解释为字符串。 If the integer exceeds the bounds of a 16 bit integer, then its value and 0xffff is used. 如果整数超过16位整数的边界,则使用其值和0xffff

This is a limitation of the resource compiler. 这是资源编译器的限制。 The resource format supports text IDs that only contain digits. 资源格式支持仅包含数字的文本ID。 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. 编写自己的基本资源编译器来执行任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 winrt::Microsoft::AI::MachineLearning::TensorFloat 类型转换回 ID3D12Resource - How do I convert a winrt::Microsoft::AI::MachineLearning::TensorFloat type back to ID3D12Resource 如何将新字符串添加到REG_MULTI_SZ类型的注册表项? - How to add new string to Registry Entry of type REG_MULTI_SZ? 如何读取注册表资源字符串例如“@文件名,资源”? - How to read registry resource string e.g. “@filename,resource”? 如何在mingw下从“resource.rc”生成“resource.h” - How to generate “resource.h” from “resource.rc” under mingw 如何在python中输入“\\”作为字符串 - how to type "\ as a string in python 如何从管道而不是键盘条目中读取字符串 - How to read a character string from a pipe instead of a keyboard entry 生成一个新的卷ID - generate a new Volume ID Window 编程(C++):如何检查子 window ID 是否被占用? 以及如何为子 window 生成唯一 ID? - Window Programming (C++): How to check if child window ID is occupied? and how to generate unique ID for child window? 如何为不同的项目类型使用相同的字符串资源 - How to use same string resource for different item types 如何使用 XAML 使用字符串资源设置 AppBarButton 文本 - How to set AppBarButton text with String resource using XAML
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM