GetExePath: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library)
 
No edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Links ==
{{PageAuthor|Instructor}}
; Latest version of headers "nsh.zip":
: http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost


If function used without header then put function in script before call it
{{User:Instructor/Headers/Template}}


== The Function ==
== Function Description ==
<highlight-nsis>/*
 
<highlight-nsis>
____________________________________________________________________________
____________________________________________________________________________


Line 12: Line 11:
____________________________________________________________________________
____________________________________________________________________________


2004 Shengalts Aleksander (Shengalts@mail.ru)


 
Get installer pathname ($EXEDIR with valid case for Windows 98/Me).
Get installer pathname ($EXEDIR with valid case for Windows 9X)




Syntax:
Syntax:
Call GetExePath         ; Call function
${GetExePath} $var
Pop $var               ; $var=installer pathname
</highlight-nsis>




Example:
<b>Example:</b>
Section
<highlight-nsis>Section
Call GetExePath
${GetExePath} $R0
Pop $R0  ; $R0="C:\ftp"
; $R0="C:\ftp"
SectionEnd*/
SectionEnd
</highlight-nsis>


== Function Code ==


;---------------------------------------------------------------------------
<highlight-nsis>
Function GetExePath
Function GetExePath
!define GetExePath `!insertmacro GetExePathCall`
!macro GetExePathCall _RESULT
Call GetExePath
Pop ${_RESULT}
!macroend
Push $0
Push $0
Push $1
Push $1
Push $2
Push $2
StrCpy $1 $CMDLINE 1
StrCmp $1 '"' 0 exedir
StrCpy $1 0
IntOp $1 $1 + 1
StrCpy $0 $CMDLINE 1 $1
StrCmp $0 '"' 0 -2
IntOp $1 $1 - 1
StrCpy $0 $CMDLINE $1 1
StrCpy $1 0
IntOp $1 $1 - 1
StrCpy $2 $0 1 $1
StrCmp $2 '\' 0 -2
StrCpy $0 $0 $1
goto end
exedir:
StrCpy $0 $EXEDIR
StrCpy $0 $EXEDIR
 
System::Call 'kernel32::GetLongPathNameA(t r0, t .r1, i 1024)i .r2'
end:
StrCmp $2 error +2
StrCpy $0 $1
Pop $2
Pop $2
Pop $1
Pop $1
Line 62: Line 51:
</highlight-nsis>
</highlight-nsis>


Page author: Instructor
[[Category:Disk, Path & File Functions]]

Latest revision as of 12:11, 30 November 2005

Author: Instructor (talk, contrib)


Page for NSIS 2.07 and below users

You can use the latest version of headers (recommended) or the following function code (put the function code in your script before calling it)

Function Description

____________________________________________________________________________
 
                            GetExePath
____________________________________________________________________________
 
 
Get installer pathname ($EXEDIR with valid case for Windows 98/Me).
 
 
Syntax:
${GetExePath} $var


Example:

Section
	${GetExePath} $R0
	; $R0="C:\ftp"
SectionEnd

Function Code

Function GetExePath
	!define GetExePath `!insertmacro GetExePathCall`
 
	!macro GetExePathCall _RESULT
		Call GetExePath
		Pop ${_RESULT}
	!macroend
 
	Push $0
	Push $1
	Push $2
	StrCpy $0 $EXEDIR
	System::Call 'kernel32::GetLongPathNameA(t r0, t .r1, i 1024)i .r2'
	StrCmp $2 error +2
	StrCpy $0 $1
	Pop $2
	Pop $1
	Exch $0
FunctionEnd