/usr/share/doc/nsis/Docs/AppendixC.html is in nsis-doc 2.50-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Useful Scripts</title>
<meta name="generator" content="Halibut version 1.0 (NSIS Custom Build) xhtml-backend" />
<link rel="stylesheet" href="style.css" type='text/css' />
</head>
<body>
<p><a href='AppendixB.html'>Previous</a> | <a href='Contents.html'>Contents</a> | <a href='AppendixD.html'>Next</a></p>
<ul>
<li><a class="btitle" href="AppendixC.html#C"><b>Appendix C: </b>Useful Scripts</a></li>
<ul>
<li><a href="AppendixC.html#C.1">Get Internet Explorer version</a></li>
<li><a href="AppendixC.html#C.2">Is .NET Framework installed?</a></li>
<li><a href="AppendixC.html#C.3">Is Macromedia Flash Player installed?</a></li>
<li><a href="AppendixC.html#C.4">Connect to the Internet</a></li>
<li><a href="AppendixC.html#C.5">Get Installer Filename</a></li>
<li><a href="AppendixC.html#C.6">Prevent Multiple Instances</a></li>
<li><a href="AppendixC.html#C.7">More</a></li>
</ul>
</ul>
<a name="C"></a><h1>Appendix C: Useful Scripts</h1>
<a name="C.1"></a><h2>C.1 Get Internet Explorer version</h2>
<pre> ; GetIEVersion
;
; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/
; Returns on top of stack
; 1-6 (Installed IE Version)
; or
; '' (IE is not installed)
;
; Usage:
; Call GetIEVersion
; Pop $R0
; ; at this point $R0 is "5" or whatnot
Function GetIEVersion
Push $R0
ClearErrors
ReadRegStr $R0 HKLM "Software\Microsoft\Internet Explorer" "Version"
IfErrors lbl_123 lbl_456
lbl_456: ; ie 4+
Strcpy $R0 $R0 1
Goto lbl_done
lbl_123: ; older ie version
ClearErrors
ReadRegStr $R0 HKLM "Software\Microsoft\Internet Explorer" "IVer"
IfErrors lbl_error
StrCpy $R0 $R0 3
StrCmp $R0 '100' lbl_ie1
StrCmp $R0 '101' lbl_ie2
StrCmp $R0 '102' lbl_ie2
StrCpy $R0 '3' ; default to ie3 if not 100, 101, or 102.
Goto lbl_done
lbl_ie1:
StrCpy $R0 '1'
Goto lbl_done
lbl_ie2:
StrCpy $R0 '2'
Goto lbl_done
lbl_error:
StrCpy $R0 ''
lbl_done:
Exch $R0
FunctionEnd
</pre>
<a name="C.2"></a><h2>C.2 Is .NET Framework installed?</h2>
<pre> ; IsDotNETInstalled
;
; Based on GetDotNETVersion
; http://nsis.sourceforge.net/Get_.NET_Version
;
; Usage:
; Call IsDotNETInstalled
; Pop $0
; StrCmp $0 1 found.NETFramework no.NETFramework
Function IsDotNETInstalled
Push $0
Push $1
StrCpy $0 1
System::Call "mscoree::GetCORVersion(w, i ${NSIS_MAX_STRLEN}, *i) i .r1"
StrCmp $1 0 +2
StrCpy $0 0
Pop $1
Exch $0
FunctionEnd
</pre>
<a name="C.3"></a><h2>C.3 Is Macromedia Flash Player installed?</h2>
<pre> ; IsFlashInstalled
;
; By Yazno, http://yazno.tripod.com/powerpimpit/
; Returns on top of stack
; 0 (Flash is not installed)
; or
; 1 (Flash is installed)
;
; Usage:
; Call IsFlashInstalled
; Pop $R0
; ; $R0 at this point is "1" or "0"
Function IsFlashInstalled
Push $R0
ClearErrors
ReadRegStr $R0 HKCR "CLSID\{D27CDB6E-AE6D-11cf-96B8-444553540000}" ""
IfErrors lbl_na
StrCpy $R0 1
Goto lbl_end
lbl_na:
StrCpy $R0 0
lbl_end:
Exch $R0
FunctionEnd
</pre>
<a name="C.4"></a><h2>C.4 Connect to the Internet</h2>
<pre> ; ConnectInternet (uses Dialer plug-in)
; Written by Joost Verburg
;
; This function attempts to make a connection to the internet if there is no
; connection available. If you are not sure that a system using the installer
; has an active internet connection, call this function before downloading
; files with NSISdl.
;
; The function requires Internet Explorer 3, but asks to connect manually if
; IE3 is not installed.
Function ConnectInternet
Push $R0
ClearErrors
Dialer::AttemptConnect
IfErrors noie3
Pop $R0
StrCmp $R0 "online" connected
MessageBox MB_OK|MB_ICONSTOP "Cannot connect to the internet."
Quit ;This will quit the installer. You might want to add your own error handling.
noie3:
; IE3 not installed
MessageBox MB_OK|MB_ICONINFORMATION "Please connect to the internet now."
connected:
Pop $R0
FunctionEnd
</pre>
<a name="C.5"></a><h2>C.5 Get Installer Filename</h2>
<pre> System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
;$R0 will contain the installer filename
</pre>
<a name="C.6"></a><h2>C.6 Prevent Multiple Instances</h2>
<p>Put the following code in your <a href="Chapter4.html#4.7.2.1.2">.onInit function</a>:</p>
<pre> System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
</pre>
<p>'myMutex' should be replaced by a unique value.</p>
<a name="C.7"></a><h2>C.7 More</h2>
<p>You can find more useful scripts at <a href="http://nsis.sourceforge.net/wiki/">the NSIS Wiki</a>, <a href="http://forums.winamp.com/forumdisplay.php?s=&forumid=65">the NSIS forum</a> and <a href="http://nsis.sourceforge.net/">NSIS development page</a>.</p>
<p><a href='AppendixB.html'>Previous</a> | <a href='Contents.html'>Contents</a> | <a href='AppendixD.html'>Next</a></p>
<hr />
<address>
</address>
</body>
</html>
|