我有一个单元,其implementation
部分中有一个resourcestring
。我怎样才能在另一个单位获得resourcestring
的标识符?从执行区域获取资源字符串标识符
unit Unit2;
interface
implementation
resourcestring
SampleStr = 'Sample';
end.
如果是在interface
部分提供,我可以写这样的:在一个单位的implementation
部分声明
PResStringRec(@SampleStr).Identifier
[根据艾伦鲍尔(http://stackoverflow.com/questions/30390079/how-resourcestring-identifiers-are-generated-by-delphi-complier) :“编译器根据单元名称和资源字符串标识符为每个资源字符串生成一个标识符,因此即使值发生更改也始终保持稳定。”所以你可能会尝试在运行时确定'PResStringRec(@SampleStr).Identifier',并使用确定的值作为常量(如果你真的不能修改'Unit2') – yonojoy 2016-06-16 08:06:13