Delphi How can i find a resource name from resourcestring unit

前端 未结 2 1653
慢半拍i
慢半拍i 2020-12-12 03:17

The situation is:

unit abc;

interface

resourcestring
  aabbcc = \'my text here\';

implementation

end.

From my application I received er

2条回答
  •  时光取名叫无心
    2020-12-12 04:18

    Your resourcestring is compiled into a string table resource. These are identified by a numeric identifier. The compiler maintains a map between your declared resourcestring instances, and the numeric identifiers. When you access a resourcestring the compiler knows the numeric identifier, and emits code that uses that identifier. Essentially what you are hoping to do is to be able to map from the name of your resourcestring and the numeric identifier. Unfortunately that map only exists during compilation. It is not contained in the executable.

    Your only other hope would be for the compiler to generate RTTI information for resource strings. However, it does not do this, unless I am very much mistaken.

    Given these constraints you are going to need to come up with your own mechanism to map between names and resource strings. One possibility is to avoid using the built-in resourcestring, and manage the string table resources, and their identifiers, by your own mechanisms.

提交回复
热议问题