NSIS Basic Tutorial Jinhua Edition Volume 2

nsis,.nsis

nsis,.nsis., ,.(LIFO). .nsis$0-$9$R0-$R9 .nsis:Pop(),Push(),Exch().

Push "Value 1"    #Stack:"Value 1"Push "Value 2"    #Stack:"Value 2"->"Value 1"Pop $0            #Stack:"Value 1" #$0  ontains:"Value 2"Push $0           #Stack:"Value 2"->"Value 1"Push "Value 3"    #Stack:"Value 3"->"Value 2"->"Value 1"Push "Value 4"    #Stack:"Value 4"->"Value 3"->"Value 2"->"Value 1"Exch              #Stack:"Value 3"->"Value 4"->"Value 2"->"Value 1"StrCpy $0 "Value X" Exch $0           #Stack:"Value X"->"Value 4"->"Value 2"->"Value 1"#Exchange the top value with the variable("Value X").#Now $0 contains "Value 3" Exch 3            #Stack:"Value 1"->Value 4"->"Value 2"->"Value X"#Exchanges the top value with the fourth value(thus index 3).

NSIS

OutFile "stack.exe"ShowInstDetails showSection ""    Push "Value 1"    Push "Value 2"    Pop $0    Push $0    Push "Value 3"    Push "Value 4"    Exch    StrCpy $0 "Value X"    Exch $0    Exch 3    Call Func1SectionEndFunction Func1    Pop $0    Pop $1    Pop $2    Pop $3    DetailPrint "$0"    DetailPrint "$1"    DetailPrint "$2"    DetailPrint "$3"FunctionEnd

NSIS

nsis:ContribLanguage files. Exampleslanguages.nsi

OutFile "Language.exe"LoadLanguageFile "${NSISDIR}ContribLanguage filesEnglish.nlf"LoadLanguageFile "${NSISDIR}ContribLanguage filesSimpChinese.nlf"Section ""SectionEndFunction .onInit	;Language selection dialog	Push ""	Push ${LANG_ENGLISH}	Push English	Push ${LANG_SIMPCHINESE}	Push "Simplified Chinese"	Push A ; A means auto count languages	       ; for the auto count to work the first empty push (Push "") must remain	LangDLL::LangDialog "Installer Language" "Please select the language of the installer"	Pop $LANGUAGE	StrCmp $LANGUAGE "cancel" 0 +2		AbortFunctionEnd

NSISDLL

DLL.nsis.dll.nsh. C/C++/Delphi.,nsis. nsis,. .dllnsisPlugins,.nshInclude, ,nsis:!AddPluginDir .(.dll) .nsh!AddIncludeDir .,".",nsis ,.

//extern "C"_declspec(dllexport) int add(int a,int b){	return a+b;}OutFile "UseDll.exe"ShowInstDetails showSection ""    Push "200"    Push "400"    Pop $0    Pop $1System::Call "UseDll::add(i$0,i$1)i.r2"DetailPrint "$0+$1=$2"SectionEnd

NSISNSIS

#include "windows.h"#include "../ExDLL/exdll.h"int myatoi(char *s);extern "C"_declspec(dllexport) int mul(int a,int b){	return a*b;}extern "C"_declspec(dllexport) add(HWND hwndParent, int string_size,                                char *variables, stack_t ** stacktop){	int a,b;	char temp[64];	EXDLL_INIT();	popstring(temp);	a = myatoi(temp);	popstring(temp);	b = myatoi(temp);		wsprintf(temp, "%d", a+b);	pushstring(temp);}int myatoi(char *s){	unsigned int v = 0;	if (*s == '0' && (s[1] == 'x' || s[1] == 'X')) {		s += 2;		for (;;) {			int c = *s++;			if (c >= '0' && c <= '9')				c -= '0';			else if (c >= 'a' && c <= 'f')				c -= 'a' - 10;			else if (c >= 'A' && c <= 'F')				c -= 'A' - 10;			else				break;			v <<= 4;			v += c;		}	} else if (*s == '0' && s[1] <= '7' && s[1] >= '0') {		s++;		for (;;) {			int c = *s++;			if (c >= '0' && c <= '7')				c -= '0';			else				break;			v <<= 3;			v += c;		}	} else {		int sign = 0;		if (*s == '-') {			s++;			sign++;		}		for (;;) {			int c = *s++ - '0';			if (c < 0 || c > 9)				break;			v *= 10;			v += c;		}		if (sign)			return -(int) v;	}	return (int) v;}
#NSIS!AddPluginDir .OutFile "UseDll.exe"ShowInstDetails showSection ""    Push "200"    Push "400"    Pop $0    Pop $1System::Call "UseDll::mul(i$0,i$1)i.r2"DetailPrint "$0*$1=$2"UseDll::add $0 $1Pop $2DetailPrint "$0+$1=$2"SectionEnd


Disclaimer: The content of this article is sourced from the internet. The copyright of the text, images, and other materials belongs to the original author. The platform reprints the materials for the purpose of conveying more information. The content of the article is for reference and learning only, and should not be used for commercial purposes. If it infringes on your legitimate rights and interests, please contact us promptly and we will handle it as soon as possible! We respect copyright and are committed to protecting it. Thank you for sharing.(Email:[email protected])