Get the list of Access versions installed

From NSIS Wiki
Jump to navigationJump to search
Author: jasonroo (talk, contrib)


Description

Here is a function I use to get a list of Access versions installed on a computer. Checks for 97, 2000, 2002 and 2003. Best used to display in droplist on a custom page.

The Function

;
; Finds the Access versions installed
;
; Input: none
; Output: the list of Access exe's found separated by '|'
;
; Usage
;
;    Call GetAccessExeVersions
;    Pop "$1"
;
 
!ifndef GetAccessExeVersionsMacro.Included
!define GetAccessExeVersionsMacro.Included
 
!macro GetAccessExeVersionsMacro
 
  ; Clear all errors at the beginning
  ClearErrors
  Push $R0
  Push $R1
 
  StrCpy $R0 ""
  StrCpy $R1 ""
 
  ReadRegStr $R1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\8.0\Common\InstallRoot" "OfficeBin"
  strcmp $R1 "" Nine CheckEight
  CheckEight:
    IfFileExists "$R1\msaccess.exe" 0 Nine
    StrCpy $R0 "$R0|Access 97"
 
  Nine:
    ReadRegStr $R1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\9.0\Common\InstallRoot" "Path"
    strcmp $R1 "" Ten CheckNine
  CheckNine:
    IfFileExists "$R1\msaccess.exe" 0 Ten
    StrCpy $R0 "$R0|Access 2000"
 
  Ten:
    ReadRegStr $R1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\10.0\Common\InstallRoot" "Path"
    strcmp $R1 "" Eleven CheckTen
  CheckTen:
    IfFileExists "$R1\msaccess.exe" 0 Eleven
    StrCpy $R0 "$R0|Access 2002"
 
  Eleven:
    ReadRegStr $R1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot" "Path"
    strcmp $R1 "" Done CheckEleven
  CheckEleven:
    IfFileExists "$R1\msaccess.exe" 0 Done
    StrCpy $R0 "$R0|Access 2003"
 
  Done:
    Pop $R1
    Exch $R0
 
!macroend
 
Function GetAccessExeVersions
  !insertmacro GetAccessExeVersionsMacro
FunctionEnd
 
Function un.GetAccessExeVersions
  !insertmacro GetAccessExeVersionsMacro
FunctionEnd
 
!endif