GetExeName: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated by user: Instructor (talk, contrib).)
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{|align=right
{{PageAuthor|Instructor}}
|<small>Author: [[{{ns:2}}:Instructor|Instructor]] ([[{{ns:3}}:Instructor|talk]], [[{{ns:-1}}:Contributions/Instructor|contrib]])</small>
|}
<br style="clear:both;">
== Links ==
; Latest version of headers "nsh.zip":
: http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost


If a function is used without an header, you should put the function below in your script before calling it.
{{User:Instructor/Headers/Template}}


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


Line 17: Line 12:




Get installer filename (also valid case for Windows 9X).
Get installer filename (with valid case for Windows 98/Me).




Syntax:
Syntax:
${GetExeName} $var
${GetExeName} $var
</highlight-nsis>




Example:
<b>Example:</b>
Section
<highlight-nsis>Section
${GetExeName} $R0
${GetExeName} $R0
; $R0="C:\ftp\program.exe"
; $R0="C:\ftp\program.exe"
SectionEnd*/
SectionEnd
</highlight-nsis>


== Function Code ==


;---------------------------------------------------------------------------
<highlight-nsis>
 
Function GetExeName
Function GetExeName
!define GetExeName `!insertmacro GetExeNameCall`
!define GetExeName `!insertmacro GetExeNameCall`
Line 43: Line 40:
Push $0
Push $0
Push $1
Push $1
 
Push $2
StrCpy $1 $CMDLINE 1
System::Call /NOUNLOAD 'kernel32::GetModuleFileNameA(i 0, t .r0, i 1024)'
StrCmp $1 '"' 0 kernel
System::Call 'kernel32::GetLongPathNameA(t r0, t .r1, i 1024)i .r2'
StrCpy $1 0
StrCmp $2 error +2
IntOp $1 $1 + 1
StrCpy $0 $1
StrCpy $0 $CMDLINE 1 $1
Pop $2
StrCmp $0 '"' 0 -2
IntOp $1 $1 - 1
StrCpy $0 $CMDLINE $1 1
goto end
 
kernel:
System::Call 'kernel32::GetModuleFileNameA(i 0, t .r0, i 1024) i r1'
 
end:
Pop $1
Pop $1
Exch $0
Exch $0
Line 63: Line 51:
</highlight-nsis>
</highlight-nsis>


[[{{ns:14}}:Disk, Path & File Functions]]
[[Category:Disk, Path & File Functions]]

Latest revision as of 07:22, 7 February 2006

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

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


Example:

Section
	${GetExeName} $R0
	; $R0="C:\ftp\program.exe"
SectionEnd

Function Code

Function GetExeName
	!define GetExeName `!insertmacro GetExeNameCall`
 
	!macro GetExeNameCall _RESULT
		Call GetExeName
		Pop ${_RESULT}
	!macroend
 
	Push $0
	Push $1
	Push $2
	System::Call /NOUNLOAD 'kernel32::GetModuleFileNameA(i 0, 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
FunctionEnd