Forum > Translations

Iterate Resourcestrings at runtime

(1/2) > >>

RoCkA:
Hi,
need help with this subject.

Problem:
At runtime i want to iterate through the available resourcestrings in my project and return the Value of any found resource name.
Tried with LoadResource.Find('xxx', 'RT_STRING') but only returned Nil.

Any help is very appreciated!
Thanks in advance :-*

Zvoni:
Keep a constant (global) array with the Names of the Ressources

RoCkA:

--- Quote from: Zvoni on February 19, 2026, 08:21:32 am ---Keep a constant (global) array with the Names of the Ressources

--- End quote ---

Sorry, but i think there is a misunderstanding.
I am trying to access the constants defined as resourcestring at runtime.

LeP:
EDIT: I tried this but doesn't work with Lazarus ... :(


If you are in Windows you can use the API to scan all IDs and you will have as results all resource strings of EXE.
I use it in Delphi since long times:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var Ix: Integer;     LenBuf: Integer;     Buffer: array[0..1023] of Char;begin  for Ix := 1 to 65535 do    begin      LenBuf := LoadString(HInstance, Ix, Buffer, Length(Buffer));      if LenBuf > 0 then        Writeln(Format('Resource ID: %d = %s', [Ix, Buffer]));    end;end; 

marcov:
Probably resourcestrings are not windows compatible, as Lazarus uses gettext derivatives for translations. Probably because it predates proper windows resource support.

If I take e.g. Anders Melander's  resource editor, and I run it on a lazarus binary I don't see the "stringtable" with resource strings that i see with Delphi binaries.

I also get warnings for its fileinfo record (malformed string record) and some unknown picture format warnings.

Short term, the smartest way would be to step through Lazarus' translation support to see how it accesses the strings.

See also bottom of  https://wiki.freepascal.org/Using_resourcestrings about rstconv c.s.

Navigation

[0] Message Index

[#] Next page

Go to full version