4

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

Here is a picture:

enter image description here

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;

Seems to work fine..

enter image description here

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

enter image description here

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

The DLL i used. HERE

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Dielo
  • 603
  • 2
  • 12
  • 25
  • 2
    Well, if I overlook what you're going to do (you know this won't be legal, right ?) and which library are you using (some sort of suspicious *"I found it on the Internet and don't care it might contain a virus"* library), you need to give the original window procedure back to the wizard form. Try to restore it in the `DeinitializeSetup` event. And, -4, $2 and $112 are not the well named constants ;-) – TLama Feb 12 '13 at 12:41
  • :( I Asked before in this forum... i will not use, put or give any virus, that dll is from the dll pack of inno setup (ultra), i didnt know this was a problem, i just want to customize my installer... and i need some help :( – Dielo Feb 12 '13 at 14:05
  • 2
    I see that it's not your intention, but be very careful with this. If I were virus developer, installer extensions would be a great place to play just because they're running usually elevated (what might allow the virus do whatever you need). I don't want to test that library, I just know that you need to give the original window procedure (the `OldProc` in your example) back to the wizard form before you quit. So maybe something like `SetWindowLong(WizardForm.Handle, -4, OldProc);` called from the `DeinitializeSetup` event should help you to resolve your problem. – TLama Feb 12 '13 at 14:13
  • 2
    @TLama, My thoughts exactly. What I'm doing in my setup programs, is I leave the original "about" text (for legal/moral reasons) and utilize `TranslatorNote` key (in the `isl` file) to add my own stuff. Replacing `GWL_WNDPROC` for *this* seems kinda extreme and even out of proportions... – kobik Feb 12 '13 at 18:19
  • 3
    Note that it is one of the license requirements of Inno to leave all of the existing text in here intact. If you're only adding text that's ok, but you're not permitted to change anything existing. And as kobik notes there is a simpler way to do that. – Miral Feb 12 '13 at 20:03

2 Answers2

7

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;

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;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
TLama
  • 75,147
  • 17
  • 214
  • 392
  • With Inno Setup 6, you can use [`CreateCallback(@WndProc)`](https://jrsoftware.org/ishelp/index.php?topic=isxfunc_createcallback) and you do not need the InnoCallback at all (so these can be removed: `Source: "InnoCallback.dll"` and `function WrapWindowProc`). – Martin Prikryl Sep 27 '20 at 08:44
0

Future visitors see this similar post: Inno Setup - How can I change the About dialog text?

Try to use the built-in function for this:

  • Override the AboutSetupNote or TranslatorNote message... neither of this will change the about box message but they will append to it which is the correct application of Inno Setup license.
BirukTes
  • 45
  • 10