在網路上找到的一篇
也可以用相同的方式 runtime 更改 InputBox 的按鈕 Caption
或其它 resourcestring
代碼: 選擇全部
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, forms, Dialogs,
StdCtrls;
type
Tform1 = class(Tform)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
form1: Tform1;
implementation
uses Consts; // 大部份的 resourcestring 所在 unit
{$R *.DFM}
Procedure 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;
const
NewOK: PChar = 'New OK'; // 新的 Caption 值
procedure Tform1.Button1Click(Sender: TObject);
begin
ShowMessage('TEST');
end;
initialization
HookResourceString(@SMsgDlgOK, NewOK); // SMsgDlgOK 為 consts unit 中一個變數
end.