Determine the path for an Oracle home

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


The Function

;
; Returns the path to the given Oracle home
;
;  Input: Name of the Oracle home
; Output: Path of the Oracle home
;
; Usage:
;
;    Push "Oracle8iClient"
;    Call OracleHomePath
;    Pop "$1"
;    MessageBox MB_OK|MB_ICONINFORMATION "Oracle home path: $1"
;
 
Function OracleHomePath
 
  Exch $R3      ; Name of the Oracle ome
  ; Push R0-R2 on the stack
  Push $R2
  Push $R1
  Push $R0
 
  ; Get the number of available homes
  ReadRegStr $R0 HKEY_LOCAL_MACHINE "SOFTWARE\ORACLE\ALL_HOMES" "HOME_COUNTER"
 
  ; Initialize counter variable R1
  StrCpy $R1 0
  Loop:
    IntCmp $R1 $R0 NotFound CheckHome NotFound
    CheckHome:
      ReadRegStr $R2 HKEY_LOCAL_MACHINE "SOFTWARE\ORACLE\ALL_HOMES\ID$R1" "NAME"
      StrCmp $R2 $R3 HomeFound ContinueLoop
      HomeFound:
        ReadRegStr $R2 HKEY_LOCAL_MACHINE "SOFTWARE\ORACLE\ALL_HOMES\ID$R1" "PATH"
        IfFileExists $R2 DirectoryFound DirectoryNotFound
        DirectoryFound:
          StrCpy $R3 $R2
          Goto Done
        DirectoryNotFound:
          StrCpy $R3 ""
          Goto Done
      ContinueLoop:
        IntOp $R1 $R1 + 1
        Goto Loop
 
  NotFound:
    StrCpy $R3 ""
 
  Done:
 
  ; Restore R0-R3 and put the result on the stack
  Pop $R0
  Pop $R1
  Pop $R2
  Exch $R3
 
FunctionEnd