Inno Setup-如何编辑“关于设置"对话框文本框 [英] Inno Setup - How to edit the "About Setup" dialog text box

查看:163
本文介绍了Inno Setup-如何编辑“关于设置"对话框文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编辑或替换Inno Setup的About Setup对话框文本中的文本.

I need to edit or replace the text in the About Setup dialog box text of Inno Setup.

这是一张图片:

在互联网上,我看到了以下代码:

Looking in the internet i got this code:

[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;

似乎工作正常.

但是,如果我关闭安装程序,则会收到崩溃消息.

But if i close the installer, i get crash message.

请我需要帮助来修复此代码,或提供一个更好的示例来更改关于安装程序"对话框中的文本.

Please i need help to fix this code or give a better example to change the text in the About Setup dialog text box.

我使用的DLL. 这里

推荐答案

在退出设置应用程序之前,需要将保存的原始Windows过程返回给向导表单.为此,请使用以下命令:

You need to give the saved original windows procedure back to the wizard form before you exit the setup application. To do so, use something like this:

const
  GWL_WNDPROC = -4;

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

无论如何,您可以使用更可靠的库来包装回调, InnoCallback 库.我对您使用的代码进行了回顾,并增加了对Unicode InnoSetup版本的支持,期望使用InnoCallback库:

Anyway, you can use more trustful library for wrapping callbacks, the InnoCallback library. I've made a review of the code you used and added support for Unicode InnoSetup versions, expecting the use of the InnoCallback library:

[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-如何编辑“关于设置"对话框文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆