2013-02-12 257 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