StripPath for Winamp: 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|jan}}
|<small>Author: [[{{ns:2}}:jan|jan]] ([[{{ns:3}}:jan|talk]], [[{{ns:-1}}:Contributions/jan|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== 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 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.
Line 43: Line 41:
FunctionEnd
FunctionEnd
</highlight-nsis>
</highlight-nsis>
[[Category:Other Products Version Detection Functions]]

Latest revision as of 13:55, 24 June 2005

Author: jan (talk, contrib)


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