2013-02-12 260 views
3

我需要編輯或替換Inno Setup的About Setup對話框文本中的文本。Inno Setup - 如何編輯「About Setup」對話框文本框

這裏有一個畫面:

enter image description here

在網上找我得到這個代碼:

[Setup] 
AppName=My Program 
AppVerName=My Program v 1.5 
DefaultDirName={pf}\My Program 
OutputDir=. 

[Languages] 
Name: "default"; MessagesFile: "compiler:Default.isl" 

[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 '[email protected] stdcall'; 
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external '[email protected] stdcall'; 
function WrapWFProc(Callback: TWFProc; ParamCount: Integer): Longword; external '[email protected]: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

但如果我關閉安裝程序,我會碰撞m essage。

enter image description here

請我需要幫助解決這一問題的代碼,或給一個更好的例子來改變在關於設置對話框文本框中的文本。

我使用的DLL。 HERE

+2

好吧,如果我忽略你打算做什麼(你知道這億韓元是不是合法的,對吧?)以及你正在使用哪種庫(某種可疑的「我在互聯網上發現它,並不在意它可能包含病毒庫」),則需要提供原始窗口過程回到嚮導窗體。嘗試在'DeinitializeSetup'事件中恢復它。並且,-4,$ 2和$ 112不是命名常量;-) – TLama 2013-02-12 12:41:31

+0

:(我在此論壇中被問到......我不會使用,放置或給出任何病毒,該dll來自inno setup的dll包(超),我不知道這是一個問題,我只是想定製我的安裝程序...我需要一些幫助:( – Dielo 2013-02-12 14:05:42

+2

我看到這不是你的意圖,但要非常小心,如果我是病毒的開發者,安裝程序擴展會是一個很好的地方,因爲它們通常運行得很高(可能會讓病毒做任何你需要的東西)我不想測試那個庫,我只知道你需要給出原始的窗口過程(在你的例子中是'OldProc')在退出前返回到嚮導窗體,所以也許像'SetWindowLong(WizardForm.Handle,-4,OldProc);'從'DeinitializeSetup'事件調用應該幫助你解決你的問題。 – TLama 2013-02-12 14:13:28

回答

7

在退出安裝應用程序之前,您需要將保存的原始Windows過程返回到嚮導窗體。要做到這一點,使用這樣的:

const 
    GWL_WNDPROC = -4; 

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

無論如何,你可以使用更多的信任庫包裝回調的InnoCallback庫。我讓你使用,並增加了對Unicode InnoSetup版本支持的代碼進行審查,預計使用InnoCallback庫:

[Setup] 
AppName=My Program 
AppVersion=1.5 
DefaultDirName={pf}\My Program 
OutputDir=userdocs:Inno Setup Examples Output 

[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 '[email protected]: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; 
+0

謝謝!它的工作。 – Dielo 2013-02-12 14:23:15

+0

不客氣! – TLama 2013-02-12 14:23:29