StdUtils plug-in: Difference between revisions
LoRd MuldeR (talk | contribs) |
LoRd MuldeR (talk | contribs) |
||
Line 84: | Line 84: | ||
== Download == | == Download == | ||
'''Download | '''Download latest version from GitHub:'''<br>https://github.com/lordmulder/stdutils/releases/tag/1.00 | ||
'''<font color="#888888">Download previous version:</font>'''<br><attach>StdUtils.2013-02-21.zip</attach> | |||
'''<font color="#888888">Download previous version:</font>'''<br><attach>StdUtils.2012-10-28.zip</attach> | '''<font color="#888888">Download previous version:</font>'''<br><attach>StdUtils.2012-10-28.zip</attach> |
Revision as of 22:21, 4 December 2013
Author: LoRd MuldeR (talk, contrib) |
This plug-in provides access to a number of "standard" functions from the C Standard Library, which programmers are used to from their C/C++ compilers (and other languages), but which are not available in NSIS by default. In order to keep the plug-in size as small as possible (~15 KB) and for maximum compatibility, the Visual C++ Run-Time v6.0 (MSVCRT.DLL), which is included with all versions of Windows (since Windows 2000), is used - instead of linking the Visual C++ Run-Time library into the plug-in DLL.
Many additional functions, not directly related to the C Standard Library, have sneaked in over the years. For example, this plug-in provides a wrapper for the SHFileOperation function. Moreover it provides a method for launching programs in a non-elevated way (user context) from an elevated installer (admin mode) on UAC-enabled systems (Vista and later) - see below for details! Last but not least, a version of ExecShell with "wait for process termination" feature (based on ShellExecuteEx) as well as a function to invoke "shell verbs" (e.g. for pinning items to the Taskbar in Windows 7) are provided. Overall I use this plug-in as my "Swiss army Army knife" for all the small things I needed in my NSIS-based installers but NSIS didn't provide out-of-the-box.
ANSI and Unicode builds available. Support operating systems: Windows 2000 and later.
Available Functions
StdUtils makes the following functions available in NSIS:
!define StdUtils.Time '!insertmacro _StdUtils_Time' #time() !define StdUtils.Rand '!insertmacro _StdUtils_Rand' #rand() !define StdUtils.RandMax '!insertmacro _StdUtils_RandMax' #rand() with maximum !define StdUtils.RandMinMax '!insertmacro _StdUtils_RandMinMax' #rand() with minimum/maximum !define StdUtils.RandList '!insertmacro _StdUtils_RandList' #rand() with list support !define StdUtils.FormatStr '!insertmacro _StdUtils_FormatStr' #sprintf() with one format tag (only %d supported!) !define StdUtils.FormatStr2 '!insertmacro _StdUtils_FormatStr2' #sprintf() with two format tags (only %d supported!) !define StdUtils.FormatStr3 '!insertmacro _StdUtils_FormatStr3' #sprintf() with three format tags (only %d supported!) !define StdUtils.ScanStr '!insertmacro _StdUtils_ScanStr' #sscanf() with one format tag (only %d supported!) !define StdUtils.ScanStr2 '!insertmacro _StdUtils_ScanStr2' #sscanf() with two format tags (only %d supported!) !define StdUtils.ScanStr3 '!insertmacro _StdUtils_ScanStr3' #sscanf() with three format tags (only %d supported!) !define StdUtils.TrimStr '!insertmacro _StdUtils_TrimStr' #Remove whitspaces from string (left and right) !define StdUtils.TrimStrLeft '!insertmacro _StdUtils_TrimStrLeft' #Remove whitspaces from string (left side only) !define StdUtils.TrimStrRight '!insertmacro _StdUtils_TrimStrRight' #Remove whitspaces from string (right side only) !define StdUtils.RevStr '!insertmacro _StdUtils_RevStr' #Reverse a string !define StdUtils.SHFileMove '!insertmacro _StdUtils_SHFileMove' #SHFileOperation with FO_MOVE !define StdUtils.SHFileCopy '!insertmacro _StdUtils_SHFileCopy' #SHFileOperation with FO_COPY !define StdUtils.ExecShellAsUser '!insertmacro _StdUtils_ExecShlUser' #ShellExecute() with user context (for elevated installers) !define StdUtils.InvokeShellVerb '!insertmacro _StdUtils_InvkeShlVrb' #Invokes a Shell Verb on the specified item !define StdUtils.ExecShellWait '!insertmacro _StdUtils_ExecShlWait' #ShellExecuteEx() with process handle to wait for !define StdUtils.WaitForProc '!insertmacro _StdUtils_WaitForProc' #WaitForSingleObject() to wait for process termination !define StdUtils.GetParameter '!insertmacro _StdUtils_GetParameter' #Get the value of a specific commandline paramater !define StdUtils.GetAllParameters '!insertmacro _StdUtils_GetAllParams' #Get complete command-line, but without executable name !define StdUtils.SetVerbose '!insertmacro _StdUtils_SetVerbose' #Verbose mode (for debugging)
For details please see the manual Docs\StdUtils\StdUtils.html included in the download!
General Usage
In order to use the StdUtils plug-in in your script, simply include "StdUtils.nsh" and then use the pre-defined ${StdUtils.FunctionName} macros like this:
!include 'StdUtils.nsh' Section ${StdUtils.Rand} $1 DetailPrint "Random number obtained via StdUtils::Rand is: $1" SectionEnd
Note: We highly recommend to not call the plug-in functions directly. Instead, use the pre-defind macros from StdUtils.nsh, which will ensure that the plug-in functions are used in the "proper" way.
For more details, please have a look at the example scripts located in the Examples\StdUtils directory of the download!
Acknowledgment
- The StdUtils plug-in for NSIS was created by LoRd_MuldeR.
- This plug-in has partly been inspired by the ShellExecAsUser plug-in, created by installer32.
- This plug-in has partly been inspired by the InvokeShellVerb plug-in, created by Robert Strong.
License
StdUtils plug-in for NSIS Copyright (C) 2004-2013 LoRd_MuldeR <mulder2@gmx.de> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
The author of the StdUtils plug-in Library for NSIS adds the following clarification to the GNU Lesser General Public License version 2.1: Installer programs (executables) created with NSIS (Nullsoft Scriptable Install System) that make use of the StdUtils plug-in Library (strictly through the NSIS plug-in interface) and that contain/distribute verbatim copies of the StdUtils plug-in Library are considered a "work that uses the Library"; they do not represent a derivative of the Library.
Please see the GNU Lesser General Public License (version 2.1) for details!
Download
Download latest version from GitHub:
https://github.com/lordmulder/stdutils/releases/tag/1.00
Download previous version:
StdUtils.2013-02-21.zip (128 KB)
Download previous version:
StdUtils.2012-10-28.zip (121 KB)
Download historic version:
StdUtils.2011-10-18.zip (105 KB)
Source Code
Public Git Repository:
git://github.com/lordmulder/stdutils.git (Browse)
Public SVN Repository:
http://code.google.com/p/mulder/source/browse/trunk/Utils/nsis_stdutils/
Support
Discussion thread at NSIS Forums:
http://forums.winamp.com/showthread.php?t=335435
E-Mail:
MuldeR2 (at) gmx (dot) de