Find the name of a valid Oracle home
From NSIS Wiki
Jump to navigationJump to search
Author: preisl (talk, contrib) |
The Function
; ; Returns the path to a valid Oracle home ; ; Input: none ; Output: Name of the first valid Oracle home found ; ; Usage: ; ; Call ValidOracleHome ; Pop "$1" ; MessageBox MB_OK|MB_ICONINFORMATION "Valid oracle home: $1" ; Function ValidOracleHome ; Push R0-R3 on the stack Push $R3 Push $R2 Push $R1 Push $R0 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: ; Read name and path of the Oracle home ReadRegStr $R2 HKEY_LOCAL_MACHINE "SOFTWARE\ORACLE\ALL_HOMES\ID$R1" "NAME" ReadRegStr $R3 HKEY_LOCAL_MACHINE "SOFTWARE\ORACLE\ALL_HOMES\ID$R1" "PATH" ; Check whether the path exists IfFileExists $R3 DirectoryFound ContinueLoop DirectoryFound: StrCpy $R3 $R2 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