; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
                               
#define MyAppName "Markdown To CHM(LME)"        
#define MyAppVersion "0.0.4.34"
#define MyAppPublisher "LunarSF"
#define MyAppExeName "LunarMarkdownEditor.exe"


[code] 
//�ж��Ƿ�װ��ָ���汾�� .NET Framework �Ĵ��������ڣ�http://www.kynosarges.org/DotNetVersion.html
function IsDotNetDetected(version: string; service: cardinal): boolean;
// Indicates whether the specified version and service pack of the .NET Framework is installed.
//
// version -- Specify one of these strings for the required .NET Framework version:
//    'v1.1'          .NET Framework 1.1
//    'v2.0'          .NET Framework 2.0
//    'v3.0'          .NET Framework 3.0
//    'v3.5'          .NET Framework 3.5
//    'v4\Client'     .NET Framework 4.0 Client Profile
//    'v4\Full'       .NET Framework 4.0 Full Installation
//    'v4.5'          .NET Framework 4.5
//    'v4.5.1'        .NET Framework 4.5.1
//    'v4.5.2'        .NET Framework 4.5.2
//    'v4.6'          .NET Framework 4.6
//    'v4.6.1'        .NET Framework 4.6.1
//    'v4.6.2'        .NET Framework 4.6.2
//    'v4.7'          .NET Framework 4.7
//
// service -- Specify any non-negative integer for the required service pack level:
//    0               No service packs required
//    1, 2, etc.      Service pack 1, 2, etc. required
var
    key, versionKey: string;
    install, release, serviceCount, versionRelease: cardinal;
    success: boolean;
begin
    versionKey := version;
    versionRelease := 0;

    // .NET 1.1 and 2.0 embed release number in version key
    if version = 'v1.1' then begin
        versionKey := 'v1.1.4322';
    end else if version = 'v2.0' then begin
        versionKey := 'v2.0.50727';
    end

    // .NET 4.5 and newer install as update to .NET 4.0 Full
    else if Pos('v4.', version) = 1 then begin
        versionKey := 'v4\Full';
        case version of
          'v4.5':   versionRelease := 378389;
          'v4.5.1': versionRelease := 378675; // 378758 on Windows 8 and older
          'v4.5.2': versionRelease := 379893;
          'v4.6':   versionRelease := 393295; // 393297 on Windows 8.1 and older
          'v4.6.1': versionRelease := 394254; // 394271 before Win10 November Update
          'v4.6.2': versionRelease := 394802; // 394806 before Win10 Anniversary Update
          'v4.7':   versionRelease := 460798; // 460805 before Win10 Creators Update
        end;
    end;

    // installation key group for all .NET versions
    key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + versionKey;

    // .NET 3.0 uses value InstallSuccess in subkey Setup
    if Pos('v3.0', version) = 1 then begin
        success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
    end else begin
        success := RegQueryDWordValue(HKLM, key, 'Install', install);
    end;

    // .NET 4.0 and newer use value Servicing instead of SP
    if Pos('v4', version) = 1 then begin
        success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
    end else begin
        success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
    end;

    // .NET 4.5 and newer use additional value Release
    if versionRelease > 0 then begin
        success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
        success := success and (release >= versionRelease);
    end;

    result := success and (install = 1) and (serviceCount >= service);
end; 

function InitializeSetup(): Boolean;
begin
    if not IsDotNetDetected('v4.0', 0) then begin
        MsgBox('����Lunar Markdown Editor ��Ҫ .NET Framework 4.0 ����߰汾��'#13#13
            '�����뵽΢����˾�ٷ���վ���ز���װ .NET Framework 4.0 ����߰汾�İ�װ������װ,'#13
            'Ȼ�������д˰�װ����', mbInformation, MB_OK);
        result := false;
    end else
        result := true;
end;

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{B878BE65-D519-4BC8-8C79-E5D09FC91D61}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
;DefaultDirName={pf}\{#MyAppName}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir="D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LMSetup"
OutputBaseFilename="LMSetup v{#MyAppVersion}"
SetupIconFile="D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkDownEditor\App.ico"
Compression=lzma
SolidCompression=yes
VersionInfoCompany="LunarSF"
VersionInfoDescription="A Markdown Editor."
VersionInfoProductName="Markdownt To CHM(LME)"
VersionInfoProductTextVersion="{#MyAppVersion}"
VersionInfoProductVersion="{#MyAppVersion}"
VersionInfoTextVersion="{#MyAppVersion}"
VersionInfoVersion="{#MyAppVersion}"
LicenseFile="D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\LicenseFile~.txt"

[Languages]
Name: "Chinese"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
;Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\LunarMarkdownEditor.exe"; DestDir: "{app}"; Flags: ignoreversion

;��Ƕ�а�Ȩ���⣬������ǶHtml Help Workshop���ѱ�֤˳�����С�
;Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\HHW\*"; DestDir: "{app}\HHW\"; Flags: ignoreversion recursesubdirs createallsubdirs
;Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\HHW\itircl.dll"; DestDir: "{sys}"; CopyMode: alwaysskipifsameorolder; Flags: restartreplace regserver
;Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\HHW\itcc.dll"; DestDir: "{sys}"; CopyMode: alwaysskipifsameorolder; Flags: restartreplace regserver
 
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\Licenses\*"; DestDir: "{app}\Licenses\"; Flags: ignoreversion recursesubdirs createallsubdirs

Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\BetterWpfControls.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Xceed.Wpf.Toolkit.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\MarkdownSharp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\ICSharpCode.AvalonEdit.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\NSoup.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Interop.SHDocVw.dll"; DestDir: "{app}"; Flags: ignoreversion

;���Dllʵ������.Net�Դ��ģ����Բ�Ҫ��
;Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Microsoft.mshtml.dll"; DestDir: "{app}"; Flags: ignoreversion

Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\System.Windows.Interactivity.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\MahApps.Metro.dll"; DestDir: "{app}"; Flags: ignoreversion

;����LunarConcept�����ڳ�ʼ����һ��ʾ��pngͼƬ��
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\ConceptExample.png"; DestDir: "{app}"; Flags: ignoreversion

;����LunarMind�����ڳ�ʼ����һ��ʾ��pngͼƬ��
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\MindMapExample.png"; DestDir: "{app}"; Flags: ignoreversion

Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\header_icon_light.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\header_icon_dark.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\comment_light.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\comment_dark.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion

Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\region_e_dark.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\region_e_light.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\region_i_dark.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\region_i_light.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\region_q_dark.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\region_q_light.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\region_w_dark.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\region_w_light.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion

Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\menu_dark.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Images~\menu_light.png"; DestDir: "{app}\Workspace\Images~\"; Flags: ignoreversion

;jQuery2.0���ϰ汾��IE�İ汾��Ҫ�󣬶�WPF ��Frame��Ƕ��IE�汾�����ߣ��ϳ������������ﻹ��ʹ�õͰ汾��jQuery��
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\jquery-1.7.0.min.js"; DestDir: "{app}\Workspace\"; Flags: ignoreversion
;Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\json2.js"; DestDir: "{app}\Workspace\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\lesson_light.css"; DestDir: "{app}\Workspace\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\lesson_dark.css"; DestDir: "{app}\Workspace\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\presentation_light.css"; DestDir: "{app}\Workspace\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\presentation_dark.css"; DestDir: "{app}\Workspace\"; Flags: ignoreversion

Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\menu_light.css"; DestDir: "{app}\Workspace\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\menu_dark.css"; DestDir: "{app}\Workspace\"; Flags: ignoreversion

Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\menu_light.js"; DestDir: "{app}\Workspace\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\menu_dark.js"; DestDir: "{app}\Workspace\"; Flags: ignoreversion

;Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\JsAndCss\jquery.jqprint-0.3.js"; DestDir: "{app}\Workspace\"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\Workspace\Help~.html"; DestDir: "{app}\Workspace\"; Flags: ignoreversion

Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\App.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\LunarMarkdownEditor\bin\Release\App.png"; DestDir: "{app}"; Flags: ignoreversion

;Ƕ��CHM�̳�
Source: "D:\My Documents\Visual Studio 2012\Projects\LunarMarkdownEditor\Lunar_Markdown_Editor_�̳�\Lunar_Markdown_Editor_�̳�.chm"; DestDir:"{app}"; Flags: ignoreversion

; NOTE: Don't use "Flags: ignoreversion" on any shared system files
;[UninstallRun]
;Filename: "regsvr32"; Parameters:"/u itcc.dll"
;Filename: "regsvr32"; Parameters:"/u itircl.dll"

;[UninstallDelete]
;Type: files; Name:"{sys}//itcc.dll"
;Type: files; Name:"{sys}//itircl.dll"

[Registry]
Root: HKLM; Subkey: "SOFTWARE\LunarMarkdownEditor"; ValueType: String; ValueName: "FullName"; ValueData: "{app}\{#MyAppExeName}"; Flags: uninsdeletekey
Root: HKLM; Subkey: "SOFTWARE\LunarMarkdownEditor"; ValueType: String; ValueName: "Path"; ValueData: "{app}"; Flags: uninsdeletekey

;ʹ�ļ��п�ݲ˵�֧�֡��� Markdown To CHM �򿪡��˵��
Root: HKLM; Subkey: "SOFTWARE\Classes\Directory\shell\�� Markdown To CHM ��\"; ValueType: String; ValueName: "Icon"; ValueData:"{app}\{#MyAppExeName},0"; Flags: uninsdeletekey
Root: HKLM; Subkey: "SOFTWARE\Classes\Directory\shell\�� Markdown To CHM ��\command"; ValueType: String; ValueData:"{app}\{#MyAppExeName} %1"; Flags: uninsdeletekey

;32λ����WPF WebBrowser ������ IE9 ģʽ��
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"; ValueType: dword; ValueName: {#MyAppExeName}; ValueData: 9999; Flags: uninsdeletekey;

;64λ����WPF WebBrowser ������ IE9 ģʽ��
Root: HKLM; Subkey: "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"; ValueType: dword; ValueName: {#MyAppExeName}; ValueData: 9999; Flags: uninsdeletekey;

;Windows XP ���֧�� IE8.

;The value to set this key to is (taken from MSDN here) as decimal values:
;11001 (0x2EDF) : Internet Explorer 11. Webpages are displayed in IE11 Standards mode, regardless of the !DOCTYPE directive
;11000 (0x2AF8) ��Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode
;10000 (0x2710) ��Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
;10001 (0x2AF7) ��Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
;9999  (0x270F) ��Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
;9000  (0x2328) ��Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
;8888  (0x22B8) ��Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
;8000  (0x1F40) ��Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
;7000  (0x1B58) ��Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.
                
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent