Determine the path for an Oracle home: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.)
m (Adding new author and category links.)
 
(One intermediate revision by the same user 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;">
== The Function ==
== The Function ==
<highlight-nsis>
<highlight-nsis>
Line 62: Line 60:


FunctionEnd</highlight-nsis>
FunctionEnd</highlight-nsis>
[[Category:Database Functions]]

Latest revision as of 12:07, 24 June 2005

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