In Delphi you can declare strings to be stored in the String Table of the module's resource section.
resourcestring
rsExample = 'Example';
At compile-time, Delphi will assigns an ID for it and stores it in the String Table.
Is there a way to retrieve the ID of a string that is declared as a resourcestring?
The reason is that I use a package that works just like gnugettext. Some functions in System.pas (like LoadResString) are hooked, so when I use a resourcestring in an expression, it will be replaced by a different string (the translation). Of course, this is very handy, but sometimes I need the original (untranslated) text of the resourcestring.
When I am able to retrieve the resource id of the string, I can call the LoadString API to get the original text, instead of the translated text.
To get the resource id of a resourcestring, you can cast the address of the string to the
PResStringRec
type then access theIdentifier
value.Try this sample