StripPath for Winamp: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library)
 
m (Updated author and download links, and changed format of some pages.)
Line 40: Line 40:
</highlight-nsis>
</highlight-nsis>


Page author: jan
Page author: [[User:jan|jan]]

Revision as of 12:39, 23 April 2005

Description

The only way to detect the installation path of Winamp leads to reading the UninstallString, which points to an .EXE file. This function uses this executable as $INSTDIR, call this function to get the path name.

The Function

;StripPath function by Frank Nagel
Function StripPath
  Push $1
  Push $2
  StrCmp $INSTDIR "" fin
 
    StrCpy $1 $INSTDIR 1 0 ; get firstchar
    StrCmp $1 '"' "" getparent 
      ; if first char is ", let's remove "'s first.
      StrCpy $INSTDIR $INSTDIR "" 1
      StrCpy $1 0
      rqloop:
        StrCpy $2 $INSTDIR 1 $1
        StrCmp $2 '"' rqdone
        StrCmp $2 "" rqdone
        IntOp $1 $1 + 1
        Goto rqloop
      rqdone:
      StrCpy $INSTDIR $INSTDIR $1
    getparent:
    ; the uninstall string goes to an EXE, let's get the directory.
    StrCpy $1 -1
    gploop:
      StrCpy $2 $INSTDIR 1 $1
      StrCmp $2 "" gpexit
      StrCmp $2 "\" gpexit
      IntOp $1 $1 - 1
      Goto gploop
    gpexit:
    StrCpy $INSTDIR $INSTDIR $1
 
  fin:
  Pop $2
  Pop $1
FunctionEnd

Page author: jan