Get Default Oracle Home Path

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


The Function

;
; Gets the name of the default Oracle Home path
;
; Usage:
;
;    Call GetOracleDefaultHomePath
;    Pop $0
;
 
Function GetOracleDefaultHomePath
  Push $R1
  Push $R2
  Push $R3
  Push $R4
 
  ; Get the name of the default home
  ReadRegStr $R1 HKLM "SOFTWARE\ORACLE\ALL_HOMES" "DEFAULT_HOME"
  StrCmp $R1 "" done
 
  ; Get the number of homes
  ReadRegStr $R4 HKLM "SOFTWARE\ORACLE\ALL_HOMES" "HOME_COUNTER"
 
  ; Loop through all homes
  StrCpy $R3 0
loop:
  IntCmp $R3 $R4 not_found 0 not_found
 
  ; Compare the home name to the default home name
  ReadRegStr $R2 HKLM "SOFTWARE\ORACLE\ALL_HOMES\ID$R3" "NAME"
  StrCmp $R2 $R1 0 next
 
  ; Verify the path of the home
  ReadRegStr $R2 HKLM "SOFTWARE\ORACLE\ALL_HOMES\ID$R3" "PATH"
  IfFileExists $R2 0 bad_home
  StrCpy $R1 $R2
  GoTo done
bad_home:
  StrCpy $R1 ""
  GoTo done
next:
  IntOp $R3 $R3 + 1
  GoTo loop
not_found:
  StrCpy $R1 ""
 
done:
  Pop $R4
  Pop $R3
  Pop $R2
  Exch $R1
FunctionEnd