乐者为王

Do one thing, and do it well.

修复wxWidgets Wizard for Visual Studio 2005/2008中的一个bug

前面发布的wxWidgets Wizard for Visual Studio 2005/2008存在一个bug,安装在VS2008中后不能创建新的wxWidgets项目。原因是没有将wxAppWiz.vsz文件中VsWizardEngine的版本号改为9.0。现在做了一些修改,修改后的代码如下:

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
procedure CurStepChanged(CurStep: TSetupStep);
var
    i: Integer;
    Signature: String;
    ConfigLine: String;
    ConfigFile: String;
    ConfigFileLines: TArrayOfString;
begin
    if CurStep = ssPostInstall then begin
        if (Pos('Visual Studio 9.0', ExpandConstant('{app}')) > 0) then begin
            Signature := 'Wizard=VsWizard.VsWizardEngine';
            ConfigFile := ExpandConstant('{app}\VCProjects\wxAppWiz.vsz');
            LoadStringsFromFile(ConfigFile, ConfigFileLines);
            for i := 0 to GetArrayLength(ConfigFileLines) - 1 do begin
                if (Pos(Signature, ConfigFileLines[i]) > 0) then begin
                    ConfigFileLines[i] := 'Wizard=VsWizard.VsWizardEngine.9.0'
                    SaveStringsToFile(ConfigFile, ConfigFileLines, False);
                    break;
                end;
            end;
        end;

        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;

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

Comments