Get installer filename: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.) |
m (Updated author links.) |
||
Line 1: | Line 1: | ||
{|align=right | |||
|<small>Author: [[{{ns:2}}:Afrow UK|Afrow UK]] ([[{{ns:3}}:Afrow UK|talk]], [[{{ns:-1}}:Contributions/Afrow UK|contrib]])</small> | |||
|} | |||
<br style="clear:both;"> | |||
== METHOD 1: USING THE WINDOWS API (RECOMMENDED) == | == METHOD 1: USING THE WINDOWS API (RECOMMENDED) == | ||
=== The Script === | === The Script === | ||
Line 57: | Line 61: | ||
FunctionEnd | FunctionEnd | ||
</highlight-nsis> | </highlight-nsis> | ||
Revision as of 02:58, 30 April 2005
Author: Afrow UK (talk, contrib) |
METHOD 1: USING THE WINDOWS API (RECOMMENDED)
The Script
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1' ;$R0 will contain the installer filename
METHOD 2: GET FROM THE COMMAND LINE
Note: If the installer is executed using the console, the command line might not contain the current folder or the .exe extension.
Usage
Call GetAppName Pop $R0 ;Installer filename
The Function
Function GetAppName Push $R0 Push $R1 Push $R2 Push $R3 StrCpy $R2 1 StrLen $R3 $CMDLINE ;Check for quote or space StrCpy $R0 $CMDLINE $R2 StrCmp $R0 '"' 0 +3 StrCpy $R1 '"' Goto loop StrCpy $R1 " " loop: IntOp $R2 $R2 + 1 StrCpy $R0 $CMDLINE 1 $R2 StrCmp $R0 $R1 get StrCmp $R2 $R3 get Goto loop get: StrCmp $R1 '"' 0 +4 IntOp $R2 $R2 - 1 StrCpy $R0 $CMDLINE $R2 1 Goto exit StrCpy $R0 $CMDLINE $R2 exit: Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd