GetExePath: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
Line 44: Line 44:


Push $0
Push $0
Push $1
Push $2
StrCpy $0 $EXEDIR
StrCpy $0 $EXEDIR
System::Call 'kernel32::GetLongPathNameA(t r0, t .r0, i 1024)'
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
Exch $0
FunctionEnd
FunctionEnd

Revision as of 20:42, 4 August 2005

Author: Instructor (talk, contrib)


Links

Latest version of headers "nsh.zip"
http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost

If a function is used without header, put the function code in your script before calling it.

The Function Description

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


Example:

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

The 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