4

About SetupInno Setup のダイアログ ボックス テキストのテキストを編集または置換する必要があります。

ここに写真があります:

ここに画像の説明を入力

インターネットを見ると、次のコードが得られました。

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

うまくいくようです..

ここに画像の説明を入力

しかし、インストーラーを閉じると、クラッシュ メッセージが表示されます。

ここに画像の説明を入力

このコードを修正するには、ヘルプが必要です。または、[セットアップについて] ダイアログ ボックスのテキストを変更するためのより良い例を挙げてください。

私が使用したDLL。 ここ

4

1 に答える 1

7

セットアップ アプリケーションを終了する前に、保存した元の Windows 手順をウィザード フォームに戻す必要があります。これを行うには、次のようなものを使用します。

const
  GWL_WNDPROC = -4;

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

とにかく、コールバックをラップするためのより信頼できるライブラリであるライブラリを使用できますInnoCallbackInnoCallbackライブラリの使用を期待して、使用したコードを確認し、Unicode InnoSetup バージョンのサポートを追加しました。

[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;
于 2013-02-12T14:21:35.497 に答える