Determine the version of MS Access: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.)
m (→‎Description: fix broken wiki links/syntax)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{|align=right
{{PageAuthor|preisl}}
|<small>Author: [[{{ns:2}}:preisl|preisl]] ([[{{ns:3}}:preisl|talk]], [[{{ns:-1}}:Contributions/preisl|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== Description ==
This function determines the MS Access version by checking some registry keys.
This function determines the MS Access version by checking some registry keys.
Note: This script does not cover newer versions or 64-bit versions of Office.


== The Function ==
== The Function ==
Line 12: Line 12:
;
;
;  Input: None
;  Input: None
; Output: 97,2000,XP
; Output: 97,2000,XP,2003
;
;
; Usage:
; Usage:
Line 28: Line 28:


   ClearErrors
   ClearErrors
   ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\10.0\Access\InstallRoot" "Path"
   ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\11.0\Access\InstallRoot" "Path"
   IfErrors SearchForVersion2000
   IfErrors SearchForVersionXP
   StrCpy $R1 "XP"
   StrCpy $R1 "2003"
   Goto Found
   Goto Found
  SearchForVersionXP:
    ClearErrors
    ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\10.0\Access\InstallRoot" "Path"
    IfErrors SearchForVersion2000
    StrCpy $R1 "XP"
    Goto Found


   SearchForVersion2000:
   SearchForVersion2000:
Line 57: Line 64:
FunctionEnd
FunctionEnd
</highlight-nsis>
</highlight-nsis>
[[Category:Database Functions]]

Latest revision as of 11:03, 12 May 2017

Author: preisl (talk, contrib)


Description

This function determines the MS Access version by checking some registry keys.

Note: This script does not cover newer versions or 64-bit versions of Office.

The Function

;
; Determines the MS Access version by finding the correct registry key
;
;  Input: None
; Output: 97,2000,XP,2003
;
; Usage:
;
;    Call AccessVersion
;    Pop "$1"
;    MessageBox MB_OK|MB_ICONINFORMATION "Access version: $1"
;
 
Function AccessVersion
 
  ; Save R0,R1 on the stack
  Push $R1
  Push $R0
 
  ClearErrors
  ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\11.0\Access\InstallRoot" "Path"
  IfErrors SearchForVersionXP
  StrCpy $R1 "2003"
  Goto Found
 
  SearchForVersionXP:
    ClearErrors
    ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\10.0\Access\InstallRoot" "Path"
    IfErrors SearchForVersion2000
    StrCpy $R1 "XP"
    Goto Found
 
  SearchForVersion2000:
    ClearErrors
    ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\9.0\Access\InstallRoot" "Path"
    IfErrors SearchForVersion97
    StrCpy $R1 "2000"
    Goto Found
 
  SearchForVersion97:
    ClearErrors
    ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Office\8.0\Access\Options" ""
    IfErrors NotFound
    StrCpy $R1 "97"
    Goto Found
 
  NotFound:
    ; MessageBox MB_OK|MB_ICONEXCLAMATION "NSIS was not able to detect your MS Access version"
    StrCpy $R1 ""
 
  Found:
  Pop $R0
  Exch $R1
 
FunctionEnd