Hello! Is there a way to change a resource string in run-time?
Hello! Is there a way to change a resource string in run-time?
My case, I need to change the Dialog messages to another language.
Example: SMsgDlgYes = 'Oui';
My case, I need to change the Dialog messages to another language.
Example: SMsgDlgYes = 'Oui';
docwiki.embarcadero.com - Using Resource DLLs - RAD Studio
ReplyDeletedxgettext and probably all other translation tools can do that.
ReplyDeleteThank you, I will take a look
ReplyDeleteI'm not vouching for it's quality, but we've been using the code below with no problems for many years. I can't recall where I found it online originally:
ReplyDeleteprocedure HookResourceString(rs: PResStringRec; newStr: PChar);
var
OldProtect: DWORD;
begin
VirtualProtect(rs, SizeOf(rs^), PAGE_EXECUTE_READWRITE, @OldProtect);
rs^.Identifier := Integer(newStr);
VirtualProtect(rs, SizeOf(rs^), OldProtect, @OldProtect);
end; { HookResourceString }
HookResourceString(@SMsgDlgOK, PChar(OurNewString); {first arg is from CONSTS.PAS }
Tom Field I hope it works with FMX too
ReplyDeleteMagno Lima It should with FMX on Windows; it won't work on other platforms
ReplyDelete