gpt4 book ai didi

inno-setup - Inno Setup - 如何编辑 "About Setup"对话框文本框

转载 作者:行者123 更新时间:2023-12-04 02:27:05 29 4
gpt4 key购买 nike

我需要编辑或替换 About Setup 中的文本Inno Setup 的对话框文本。
这是一张图片:
enter image description here
在互联网上查看我得到了这个代码:

[Files]
Source: CallbackCtrl.dll; Flags: dontcopy

[Code]
type
TWFProc = function(h:hWnd;Msg,wParam,lParam:Longint):Longint;

function CallWindowProc(lpPrevWndFunc: Longint; hWnd: HWND; Msg: UINT; wParam: Longint; lParam: Longint): Longint; external 'CallWindowProcA@user32.dll stdcall';
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function WrapWFProc(Callback: TWFProc; ParamCount: Integer): Longword; external 'wrapcallbackaddr@files:CallbackCtrl.dll stdcall';

var
OldProc:Longint;

procedure AboutSetupClick;
begin
//Edit your text here
MsgBox('CUSTOM TEXT HERE', mbInformation, MB_OK);
end;

function WFWndProc(h:HWND;Msg,wParam,lParam:Longint):Longint;
begin
if (Msg=$112) and (wParam=9999) then begin
Result:=0;
AboutSetupClick;
end else begin
if Msg=$2 then SetWindowLong(WizardForm.Handle,-4,OldProc);
Result:=CallWindowProc(OldProc,h,Msg,wParam,lParam);
end;
end;

procedure InitializeWizard;
begin
OldProc:=SetWindowLong(WizardForm.Handle,-4,WrapWFProc(@WFWndProc,4));
end;
似乎工作正常..
enter image description here
但是如果我关闭安装程序,我会收到崩溃消息。
enter image description here
请我需要帮助来修复此代码或提供一个更好的示例来更改“关于设置”对话框文本框中的文本。
我使用的DLL。
HERE

最佳答案

在退出安装应用程序之前,您需要将保存的原始 Windows 过程返回给向导表单。为此,请使用以下内容:

const
GWL_WNDPROC = -4;

procedure DeinitializeSetup;
begin
SetWindowLong(WizardForm.Handle, GWL_WNDPROC, OldProc);
end;
无论如何,您可以使用更可靠的库来包装回调, InnoCallback 图书馆。我已经审查了您使用的代码并添加了对 Unicode InnoSetup 版本的支持,期待使用 InnoCallback图书馆:
[Files]
Source: "InnoCallback.dll"; DestDir: "{tmp}"; Flags: dontcopy

[Code]
#ifdef UNICODE
#define AW "W"
#else
#define AW "A"
#endif
const
GWL_WNDPROC = -4;
SC_ABOUTBOX = 9999;
WM_SYSCOMMAND = $0112;

type
WPARAM = UINT_PTR;
LPARAM = LongInt;
LRESULT = LongInt;
TWindowProc = function(hwnd: HWND; uMsg: UINT; wParam: WPARAM;
lParam: LPARAM): LRESULT;

function CallWindowProc(lpPrevWndFunc: LongInt; hWnd: HWND; Msg: UINT;
wParam: WPARAM; lParam: LPARAM): LRESULT;
external 'CallWindowProc{#AW}@user32.dll stdcall';
function SetWindowLong(hWnd: HWND; nIndex: Integer;
dwNewLong: LongInt): LongInt;
external 'SetWindowLong{#AW}@user32.dll stdcall';
function WrapWindowProc(Callback: TWindowProc; ParamCount: Integer): LongWord;
external 'wrapcallback@files:InnoCallback.dll stdcall';

var
OldWndProc: LongInt;

procedure ShowAboutBox;
begin
MsgBox('Hello, I''m your about box!', mbInformation, MB_OK);
end;

function WndProc(hwnd: HWND; uMsg: UINT; wParam: WPARAM;
lParam: LPARAM): LRESULT;
begin
if (uMsg = WM_SYSCOMMAND) and (wParam = SC_ABOUTBOX) then
begin
Result := 0;
ShowAboutBox;
end
else
Result := CallWindowProc(OldWndProc, hwnd, uMsg, wParam, lParam);
end;

procedure InitializeWizard;
begin
OldWndProc := SetWindowLong(WizardForm.Handle, GWL_WNDPROC,
WrapWindowProc(@WndProc, 4));
end;

procedure DeinitializeSetup;
begin
SetWindowLong(WizardForm.Handle, GWL_WNDPROC, OldWndProc);
end;

关于inno-setup - Inno Setup - 如何编辑 "About Setup"对话框文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14828144/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com