tools/installer/nsis/includes/system.nsh
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       
     2 ;;
       
     3 ;; Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ;; All rights reserved.
       
     5 ;; Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 ;;
       
     7 ;; This file is part of the tools applications of the Qt Toolkit.
       
     8 ;;
       
     9 ;; $QT_BEGIN_LICENSE:LGPL$
       
    10 ;; No Commercial Usage
       
    11 ;; This file contains pre-release code and may not be distributed.
       
    12 ;; You may use this file in accordance with the terms and conditions
       
    13 ;; contained in the Technology Preview License Agreement accompanying
       
    14 ;; this package.
       
    15 ;;
       
    16 ;; GNU Lesser General Public License Usage
       
    17 ;; Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ;; General Public License version 2.1 as published by the Free Software
       
    19 ;; Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ;; packaging of this file.  Please review the following information to
       
    21 ;; ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ;; will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 ;;
       
    24 ;; In addition, as a special exception, Nokia gives you certain additional
       
    25 ;; rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ;; version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 ;;
       
    28 ;; If you have questions regarding the use of this file, please contact
       
    29 ;; Nokia at qt-info@nokia.com.
       
    30 ;;
       
    31 ;;
       
    32 ;;
       
    33 ;;
       
    34 ;;
       
    35 ;;
       
    36 ;;
       
    37 ;;
       
    38 ;; $QT_END_LICENSE$
       
    39 ;;
       
    40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       
    41 !ifndef SYSTEM_INCLUDE
       
    42 !define SYSTEM_INCLUDE
       
    43 
       
    44 !define QTVSIP2003_GUID "{789202F4-94F5-4f0a-AA00-73295FEBFD68}"
       
    45 !define QTVSIP2005_GUID "{789202F4-94F5-4f0a-AA00-73295FEBFD69}"
       
    46 
       
    47 !define QMSNET2002_GUID "{C174ACCD-D856-4B60-9887-0FF9E841E0EC}"
       
    48 !define QMSNET2003_GUID "{C174ACCE-D857-4B61-9888-0FF9E841E0ED}"
       
    49 !define QMSNET2005_GUID "{14E98DB4-A232-49a4-8EC1-8CE4F6985C73}"
       
    50 
       
    51 !macro GetVSInstallationDir UN
       
    52 ; Usage:
       
    53 ;
       
    54 ;   push "7.0"
       
    55 ;   call GetVSInstallationDir
       
    56 ;   pop $0
       
    57 ;
       
    58 ; If the requested VS version can be found, its
       
    59 ; installation directory is returned.
       
    60 Function ${UN}GetVSInstallationDir
       
    61   Exch $0
       
    62   Push $1
       
    63   ReadRegStr $1 HKLM "Software\Microsoft\VisualStudio\$0" "InstallDir"
       
    64   StrCpy $0 $1
       
    65   StrCmp $0 "" 0 +2
       
    66     SetErrors
       
    67   Pop $1
       
    68   Exch $0
       
    69 FunctionEnd
       
    70 !macroend
       
    71 
       
    72 !insertmacro GetVSInstallationDir ""
       
    73 !insertmacro GetVSInstallationDir "un."
       
    74 
       
    75 
       
    76 !macro IsDotNETInstalled UN
       
    77 ; Usage:
       
    78 ;
       
    79 ;  push "8.0"
       
    80 ;  call IsDotNETInstalled
       
    81 ;  pop $0
       
    82 ;
       
    83 ;  $0 contains the path where the .NET framework is installed.
       
    84 ;  If not installation can be found $0 is empty.
       
    85 Function ${UN}IsDotNETInstalled
       
    86   Exch $0
       
    87   Push $1
       
    88   Push $2
       
    89   Push $3
       
    90   Push $4
       
    91   Push $5
       
    92   
       
    93   StrCpy $5 $0
       
    94 
       
    95   ReadRegStr $4 HKEY_LOCAL_MACHINE "Software\Microsoft\.NETFramework" "InstallRoot"
       
    96   Push $4
       
    97   Exch $EXEDIR
       
    98   Exch $EXEDIR
       
    99   Pop $4
       
   100 
       
   101   IfFileExists $4 0 noDotNET
       
   102   StrCpy $0 0
       
   103 
       
   104   EnumStart:
       
   105   EnumRegKey $2 HKEY_LOCAL_MACHINE "Software\Microsoft\.NETFramework\Policy"  $0
       
   106   IntOp $0 $0 + 1
       
   107   StrCmp $2 "" noDotNET
       
   108   StrCpy $1 0
       
   109 
       
   110   EnumPolicy:
       
   111   EnumRegValue $3 HKEY_LOCAL_MACHINE "Software\Microsoft\.NETFramework\Policy\$2" $1
       
   112   IntOp $1 $1 + 1
       
   113   StrCmp $3 "" EnumStart
       
   114 
       
   115   StrCmp $5 "8.0" 0 +2
       
   116     StrCmp $2 "v2.0" 0 EnumPolicy
       
   117 
       
   118   IfFileExists "$4\$2.$3" foundDotNET EnumPolicy
       
   119 
       
   120   noDotNET:
       
   121   StrCpy $0 0
       
   122   Goto done
       
   123 
       
   124   foundDotNET:
       
   125   StrCpy $0 "$4\$2.$3"
       
   126 
       
   127   done:
       
   128   Pop $5
       
   129   Pop $4
       
   130   Pop $3
       
   131   Pop $2
       
   132   Pop $1
       
   133   Exch $0
       
   134 FunctionEnd
       
   135 !macroend
       
   136 
       
   137 !insertmacro IsDotNETInstalled ""
       
   138 !insertmacro IsDotNETInstalled "un."
       
   139 
       
   140 !macro IsQMsNetInstalled UN
       
   141 ; Usage:
       
   142 ;
       
   143 ;  push "8.0"
       
   144 ;  call IsQMsNetInstalled
       
   145 ;  pop $0
       
   146 Function ${UN}IsQMsNetInstalled
       
   147   Exch $0
       
   148   Push $1
       
   149   Push $2
       
   150   Push $3
       
   151   
       
   152   StrCmp $0 "7.0" 0 +2
       
   153     StrCpy $2 "${QMSNET2002_GUID}"
       
   154   StrCmp $0 "7.1" 0 +2
       
   155     StrCpy $2 "${QMSNET2003_GUID}"
       
   156   StrCmp $0 "8.0" 0 +2
       
   157     StrCpy $2 "${QMSNET2005_GUID}"
       
   158 
       
   159   StrCpy $3 0
       
   160 
       
   161   ReadRegStr $1 HKLM "SOFTWARE\Microsoft\VisualStudio\$0\NewProjectTemplates\TemplateDirs\$2\/2" "TemplatesDir"
       
   162   StrCmp $1 "" +3
       
   163     StrCpy $3 1
       
   164     goto done
       
   165 
       
   166   ReadRegStr $1 HKCU "SOFTWARE\Microsoft\VisualStudio\$0\NewProjectTemplates\TemplateDirs\$2\/2" "TemplatesDir"
       
   167   StrCmp $1 "" +2
       
   168     StrCpy $3 1
       
   169 
       
   170 done:
       
   171   StrCpy $0 $3
       
   172 
       
   173   Pop $3
       
   174   Pop $2
       
   175   Pop $1
       
   176   Exch $0
       
   177 FunctionEnd
       
   178 !macroend
       
   179 
       
   180 !insertmacro IsQMsNetInstalled ""
       
   181 !insertmacro IsQMsNetInstalled "un."
       
   182 
       
   183 !macro IsQMsDevInstalled UN
       
   184 ; Usage:
       
   185 ;
       
   186 ;  call IsQMsDevInstalled
       
   187 ;  pop $0
       
   188 Function ${UN}IsQMsDevInstalled
       
   189   Push $0
       
   190   Push $1
       
   191   Push $2
       
   192 
       
   193   StrCpy $0 0
       
   194 
       
   195   ReadRegStr $1 HKLM "SOFTWARE\Microsoft\DevStudio\6.0\AddIns\q4msdev.Q4MsDev.1" "Filename"
       
   196   StrCmp $1 "" +3
       
   197     StrCpy $0 1
       
   198     goto done
       
   199 
       
   200   ReadRegStr $1 HKCU "SOFTWARE\Microsoft\DevStudio\6.0\AddIns\q4msdev.Q4MsDev.1" "Filename"
       
   201   StrCmp $1 "" +2
       
   202     StrCpy $0 1
       
   203 
       
   204 done:
       
   205   Pop $2
       
   206   Pop $1
       
   207   Exch $0
       
   208 FunctionEnd
       
   209 !macroend
       
   210 
       
   211 !insertmacro IsQMsDevInstalled ""
       
   212 !insertmacro IsQMsDevInstalled "un."
       
   213 
       
   214 !macro IsIntegrationInstalled UN
       
   215 ; Usage:
       
   216 ;
       
   217 ;  push "8.0"
       
   218 ;  call IsIntegrationInstalled
       
   219 ;  pop $0
       
   220 Function ${UN}IsIntegrationInstalled
       
   221   Exch $0
       
   222   Push $1
       
   223   Push $2
       
   224 
       
   225   StrCmp $0 "7.1" 0 +2
       
   226     StrCpy $2 "${QTVSIP2003_GUID}"
       
   227   StrCmp $0 "8.0" 0 +2
       
   228     StrCpy $2 "${QTVSIP2005_GUID}"
       
   229 
       
   230   ReadRegStr $1 HKLM "SOFTWARE\Microsoft\VisualStudio\$0\Packages\$2" "ProductName"
       
   231   
       
   232   StrCpy $0 0
       
   233   StrCmp $1 "" done
       
   234     StrCpy $0 1
       
   235 
       
   236 done:
       
   237   Pop $2
       
   238   Pop $1
       
   239   Exch $0
       
   240 FunctionEnd
       
   241 !macroend
       
   242 
       
   243 !insertmacro IsIntegrationInstalled ""
       
   244 !insertmacro IsIntegrationInstalled "un."
       
   245 
       
   246 !macro AdministratorRights UN
       
   247 Function ${UN}HasAdminRights
       
   248   push $0
       
   249   ClearErrors
       
   250   UserInfo::GetAccountType
       
   251   IfErrors Yes ;It's probably Win95
       
   252   pop $0
       
   253   StrCmp $0 "Admin" Yes
       
   254   StrCmp $0 "Power" Yes
       
   255 
       
   256   StrCpy $0 "false"
       
   257   goto Done
       
   258 
       
   259   Yes:
       
   260   StrCpy $0 "true"
       
   261 
       
   262   Done:
       
   263   exch $0
       
   264 FunctionEnd
       
   265 !macroend
       
   266 !insertmacro AdministratorRights ""
       
   267 !insertmacro AdministratorRights "un."
       
   268 
       
   269 !endif ;SYSTEM_INCLUDE