乐者为王

Do one thing, and do it well.

完成了wxWidgets Wizard for Visual Studio 2005/2008的安装程序

两个晚上的时间,一边查资料一边学习,同时编写和测试安装脚本,最终完成了wxWidgets Wizard for Visual Studio 2005/2008的安装程序。现在不用配置就可以使用wxWidgets Wizard的代码框架生成功能了。安装制作程序采用的是Inno Setup,完整的安装脚本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#define SrcImgsDir '..\VCWizards\images'
#define SrcHtmlDir '..\VCWizards\html\1033'
#define SrcScptDir '..\VCWizards\scripts\1033'
#define SrcTempDir '..\VCWizards\templates\1033'
#define TgtImgsDir 'VCWizards\AppWiz\wxWidgets\Application\images'
#define TgtHtmlDir 'VCWizards\AppWiz\wxWidgets\Application\html\1033'
#define TgtScptDir 'VCWizards\AppWiz\wxWidgets\Application\scripts\1033'
#define TgtTempDir 'VCWizards\AppWiz\wxWidgets\Application\templates\1033'

[Setup]
AppName=wxWidgets Application Wizard
AppVerName=wxWidgets Wizard 1.0.0
AppPublisher=dohkoos
DefaultDirName={pf32}\Microsoft Visual Studio 9.0\VC
DirExistsWarning=no
;Uninstallable=no
UninstallFilesDir={app}\VCWizards\AppWiz\wxWidgets
UninstallDisplayIcon={app}\VCProjects\wxAppWiz.ico
Compression=lzma
SolidCompression=yes

[Files]
Source: ..\VCProjects\wxAppWiz.ico; DestDir: {app}\VCProjects
Source: ..\VCProjects\wxAppWiz.vsz; DestDir: {app}\VCProjects
Source: ..\VCProjects\wxWidgets\wxWidgets.vsdir; DestDir: {app}\VCProjects\wxWidgets
Source: {#SrcImgsDir}\*.gif; DestDir: {app}\{#TgtImgsDir}
Source: {#SrcHtmlDir}\*.htm; DestDir: {app}\{#TgtHtmlDir}
Source: {#SrcHtmlDir}\*.css; DestDir: {app}\{#TgtHtmlDir}
Source: {#SrcScptDir}\*.js; DestDir: {app}\{#TgtScptDir}
Source: {#SrcTempDir}\*.h; DestDir: {app}\{#TgtTempDir}
Source: {#SrcTempDir}\*.cpp; DestDir: {app}\{#TgtTempDir}
Source: {#SrcTempDir}\readme.txt; DestDir: {app}\{#TgtTempDir}
Source: {#SrcTempDir}\root.manifest; DestDir: {app}\{#TgtTempDir}
Source: {#SrcTempDir}\Templates.inf; DestDir: {app}\{#TgtTempDir}

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
    i: Integer;
    Signature: String;
    ConfigLine: String;
    ConfigFile: String;
    ConfigFileLines: TArrayOfString;
begin
    if CurStep = ssPostInstall then begin
        Signature := 'wxWidgets';
        ConfigLine := 'wxWidgets|{1B027A40-8F43-11D0-8D11-00A0C91BC942}|#1043|70' + #13#10;
        ConfigFile := ExpandConstant('{app}\VCProjects\vc.vsdir');
        LoadStringsFromFile(ConfigFile, ConfigFileLines);
        for i := 0 to GetArrayLength(ConfigFileLines) - 1 do begin
            if (Pos(Signature, ConfigFileLines[i]) > 0) then abort;
        end;
        SaveStringToFile(ConfigFile, ConfigLine, True);
    end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
    i: Integer;
    j: Integer;
    Signature: String;
    ConfigFile: String;
    ConfigFileLines, NewConfigFileLines: TArrayOfString;
begin
    if CurUninstallStep = usUninstall then begin
        Signature := 'wxWidgets';
        ConfigFile := ExpandConstant('{app}\VCProjects\vc.vsdir');
        LoadStringsFromFile(ConfigFile, ConfigFileLines);
        SetArrayLength(NewConfigFileLines, GetArrayLength(ConfigFileLines) - 1);
        j := 0;
        for i := 0 to GetArrayLength(ConfigFileLines) - 1 do begin
            if (Pos(Signature, ConfigFileLines[i]) > 0) then begin
                continue;
            end else begin
                NewConfigFileLines[j] := ConfigFileLines[i];
                j := j + 1;
            end;
        end;
        SaveStringsToFile(ConfigFile, NewConfigFileLines, False);
    end;
end;

代码下载:https://github.com/dohkoos/wxwizard

Comments