﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-只有面对现实，你才能超越现实-随笔分类-NSIS</title><link>http://www.cppblog.com/wanghaiguang/category/19358.html</link><description>不要浪费你的生命，在你一定会后悔的地方上。
逆水行舟，不进则退</description><language>zh-cn</language><lastBuildDate>Tue, 03 Sep 2013 12:50:41 GMT</lastBuildDate><pubDate>Tue, 03 Sep 2013 12:50:41 GMT</pubDate><ttl>60</ttl><item><title>NSIS添加安装完成后提示是否运行程序</title><link>http://www.cppblog.com/wanghaiguang/archive/2013/09/02/202947.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Mon, 02 Sep 2013 06:39:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2013/09/02/202947.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/202947.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2013/09/02/202947.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/202947.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/202947.html</trackback:ping><description><![CDATA[<br /><p style="margin-top:3.75pt;margin-right:0cm;margin-bottom:3.75pt;margin-left: 0cm;line-height:16.5pt;background:white;"><span style="font-size:10.5pt;color:#111111">可以使用</span><span style="font-size:10.5pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#111111">MUI</span><span style="font-size:10.5pt;color:#111111">函数里面的</span></p>  <p style="margin: 3.75pt 0cm; line-height: 16.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><strong style="font-style: inherit;"><span style="font-size: 10.5pt; font-family: Verdana, sans-serif; color: #111111;">MUI_FINISHPAGE_RUN_FUNCTION</span></strong>&nbsp;<span style="font-size:10.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;; color:#111111">function&nbsp;</span></p>  <p style="margin: 3.75pt 0cm; line-height: 16.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;color:#111111">定义一个</span><span style="font-size:10.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;; color:#111111">function</span><span style="font-size:10.5pt;color:#111111">，函数里面执行</span> <span style="font-size:10.5pt;color:#111111">安装完成后的</span><span style="font-size:10.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;; color:#111111">exe<br /></span><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->;定义安装界面<br />!define&nbsp;MUI_FINISHPAGE_RUN<br />;安装函数定义<br />!define&nbsp;MUI_FINISHPAGE_RUN_FUNCTION&nbsp;"LaunchLink"&nbsp;<br />!insertmacro&nbsp;MUI_PAGE_FINISH<br /><br />;function要写字section之后<br />Function&nbsp;LaunchLink<br />&nbsp;&nbsp;&nbsp;&nbsp;ExecShell&nbsp;""&nbsp;"$INSTDIR\*.exe"<br />FunctionEnd</div></p><img src ="http://www.cppblog.com/wanghaiguang/aggbug/202947.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2013-09-02 14:39 <a href="http://www.cppblog.com/wanghaiguang/archive/2013/09/02/202947.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS插件大全</title><link>http://www.cppblog.com/wanghaiguang/archive/2013/01/06/197018.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Sun, 06 Jan 2013 06:33:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2013/01/06/197018.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/197018.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2013/01/06/197018.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/197018.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/197018.html</trackback:ping><description><![CDATA[<span style="font-family: 'Lucida Console'; font-size: 12pt;">附件是NSIS的一些插件，希望对大家有所帮助。</span><a title="NSIS插件下载" href="/Files/wanghaiguang/NsisPlugins_115个.rar"><br /><span style="font-family: 'Lucida Console'; font-size: 12pt;">NSIS插件下载</span></a><img src ="http://www.cppblog.com/wanghaiguang/aggbug/197018.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2013-01-06 14:33 <a href="http://www.cppblog.com/wanghaiguang/archive/2013/01/06/197018.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS结束SYSTEM权限进程</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/12/27/196729.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Thu, 27 Dec 2012 07:23:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/12/27/196729.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/196729.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/12/27/196729.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/196729.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/196729.html</trackback:ping><description><![CDATA[<span style="font-family: Verdana; font-size: 12pt;">NSIS有很多插件可以结束系统进程，例如：Processes.dll，processwork.dll，KillProcDLL.dll</span><br /><span style="font-family: Verdana; font-size: 12pt;">他们的调用格式如下：Processes::KillProcess "进程名"</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br /><span style="font-family: Verdana; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Push&nbsp;"QQ.exe</span><br /><span style="font-family: Verdana; font-size: 12pt;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Processwork::KillProcess</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><span style="font-family: Verdana; font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;KillProcDLL::KillProc "进程名"</span><br /><br /><span style="font-family: Verdana; font-size: 12pt;">如果是SYSTEM进程，则用ExecCmd插件，用法如下：</span><br /><span style="font-family: Verdana; font-size: 12pt;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;ExecCmd::exec '"taskkill" /F /IM 进程名 /T' </span><img src ="http://www.cppblog.com/wanghaiguang/aggbug/196729.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-12-27 15:23 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/12/27/196729.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[NSIS插件] ProcFunc.nsh - NSIS 进程函数头文件</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/10/18/193469.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Thu, 18 Oct 2012 06:09:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/10/18/193469.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/193469.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/10/18/193469.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/193469.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/193469.html</trackback:ping><description><![CDATA[<span style="font-family: Verdana; font-size: 12pt">来源：</span><br /><span style="font-family: Verdana; font-size: 12pt">http://portableapps.com/node/12561</span><br /><span style="font-family: Verdana; font-size: 12pt">下载</span><br /><span style="font-family: Verdana; font-size: 12pt">http://zer0dev.com/dld/download.php?id=27</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">头文件使用：</span><br /><span style="font-family: Verdana; font-size: 12pt">1. !include "ProcFunc.nsh"</span><br /><span style="font-family: Verdana; font-size: 12pt">2. 可使用范围：$var为返回值</span><br /><span style="font-family: Verdana; font-size: 12pt">[Section|Function]</span><br /><span style="font-family: Verdana; font-size: 12pt">${ProcFunction} "参数1" "参数2" "..." $var</span><br /><span style="font-family: Verdana; font-size: 12pt">[SectionEnd|FunctionEnd]</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${ProcessExists} "[process]"</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[process]"&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;; Name or PID</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; Use with a LogicLib conditional command like If or Unless.</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; Evaluates to true if the process exists or false if it does not or</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; the CreateToolhelp32Snapshot fails.</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${GetProcessPID} "[process]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[process]"&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;; Name or PID</span><br />&nbsp; &nbsp; <br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ; -2 - CreateToolhelp32Snapshot failed</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;&nbsp;&nbsp;0 - process does not exist</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;; &gt;0 - PID</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${GetProcessPath} "[process]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[process]"&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;; Name or PID</span><br />&nbsp; &nbsp; <br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ; -2 - CreateToolhelp32Snapshot failed</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;; -1 - OpenProcess failed</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;;&nbsp;&nbsp;0 - process does not exist</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;; Or path to process</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${GetProcessParent} "[process]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[process]"&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;; Name or PID</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ; -2 - CreateToolhelp32Snapshot failed</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;&nbsp;&nbsp;0 - process does not exist</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;; Or PPID</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${GetProcessName} "[PID]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[PID]"&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;; PID</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;; -2 - CreateToolhelp32Snapshot failed</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;&nbsp;&nbsp;0 - process does not exist</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Or process name</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${EnumProcessPaths} "Function" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "Function"&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ; Callback function</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ; -2 - EnumProcesses failed</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;&nbsp;&nbsp;1 - success</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; Function "Function"</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Pop $var1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; matching path string</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Pop $var2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; matching process PID</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;...user commands</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Push [1/0]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; must return 1 on the stack to continue</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; ; must return some value or corrupt the stack</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; ; DO NOT save data in $0-$9</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; FunctionEnd</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${ProcessWait} "[process]" "[timeout]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[process]"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; Name</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[timeout]"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; -1 - do not timeout</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; &gt;0 - timeout in milliseconds</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;; -2 - CreateToolhelp32Snapshot failed</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;; -1 - operation timed out</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Or PID</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${ProcessWait2} "[process]" "[timeout]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[process]"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Name</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[timeout]"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; -1 - do not timeout</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; &gt;0 - timeout in milliseconds</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;; -1 - operation timed out</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Or PID</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${ProcessWaitClose} "[process]" "[timeout]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[process]"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; Name</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[timeout]"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; -1 - do not timeout</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; &gt;0 - timeout in milliseconds</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;; -1 - operation timed out</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;&nbsp;&nbsp;0 - process does not exist</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Or PID of ended process</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${CloseProcess} "[process]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[process]"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; Name or PID</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;; 0 - process does not exist</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Or PID of ended process</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${TerminateProcess} "[process]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[process]"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; Name or PID</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;; -1 - operation failed</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;&nbsp;&nbsp;0 - process does not exist</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Or PID of ended process</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">${Execute} "[command]" "[working_dir]" $var</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[command]"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; '"X:\path\to\prog.exe" arg1 arg2 "arg3 with space"'</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; "[working_dir]"&nbsp;&nbsp;&nbsp;&nbsp; ; Working directory ("X:\path\to\dir") or nothing ("")</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp; $var(output)&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;; 0 - failed to create process</span><br /><span style="font-family: Verdana; font-size: 12pt">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Or PID</span><br /><span style="font-family: Verdana; font-size: 12pt">*/</span><br /><br /><span style="font-family: Verdana; font-size: 12pt">本文转自：</span><a href="http://www.dreams8.com/forum.php?mod=viewthread&amp;tid=17067&amp;fromuid=1"><span style="font-family: Verdana; font-size: 12pt">http://www.dreams8.com/forum.php?mod=viewthread&amp;tid=17067&amp;fromuid=1</span></a><img src ="http://www.cppblog.com/wanghaiguang/aggbug/193469.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-10-18 14:09 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/10/18/193469.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS创建互斥，退出重复运行的程序</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/10/18/193467.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Thu, 18 Oct 2012 06:02:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/10/18/193467.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/193467.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/10/18/193467.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/193467.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/193467.html</trackback:ping><description><![CDATA[<div>以下为示例脚本：
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">1</span>&nbsp;<span style="color: #000000">!</span><span style="color: #000000">define&nbsp;MyMutex_Update&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">MyMutex_Update</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">2</span>&nbsp;<span style="color: #000000"><br /></span><span style="color: #008080">3</span>&nbsp;<span style="color: #000000"><br /></span><span style="color: #008080">4</span>&nbsp;<span style="color: #000000">Section<br /></span><span style="color: #008080">5</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;System::Call&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">kernel32::CreateMutexA(i&nbsp;0,&nbsp;i&nbsp;0,&nbsp;t&nbsp;"${MyMutex_Update}")&nbsp;i&nbsp;.r1&nbsp;?e</span><span style="color: #000000">'</span><span style="color: #000000"><br /></span><span style="color: #008080">6</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;Pop&nbsp;$R0<br /></span><span style="color: #008080">7</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;StrCmp&nbsp;$R0&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">2</span><span style="color: #000000"><br /></span><span style="color: #008080">8</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;Quit<br /></span><span style="color: #008080">9</span>&nbsp;<span style="color: #000000">SectionEnd</span></div><br /><br />其他文章：<a href="http://blog.csdn.net/shemny/article/details/7575038">http://blog.csdn.net/shemny/article/details/7575038</a></div><img src ="http://www.cppblog.com/wanghaiguang/aggbug/193467.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-10-18 14:02 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/10/18/193467.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS 静默安装传递更改默认路径参数</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/05/25/176109.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Fri, 25 May 2012 01:30:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/05/25/176109.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/176109.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/05/25/176109.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/176109.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/176109.html</trackback:ping><description><![CDATA[<h2>安装程序的使用</h2>
<p>生成的安装程序和卸载程序接受一些命令行的参数。这些参数可以让用户在安装过程中对安装程序作部分控制。</p>
<h3>公共选项</h3>
<ul><li>/NCRC 禁止 CRC 检测，除非在脚本里强制使用了 <a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.8.html#4.8.1.12"><code>CRCCheck</code></a><code> force</code> 。</li><li>/S 静默运行安装程序或卸载程序。更多信息请参看 <a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.12.html#4.12">section 4.12</a> 。</li><li>/D 指定默认的安装目录 (<a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.2.html#4.2.2">$INSTDIR</a>), 可以越过 <a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.8.html#4.8.1.21">InstallDir</a> 和 <a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.8.html#4.8.1.22">InstallDirRegKey</a> 。这个参数必须是最后一个参数并且不能带任何引号即使路径带有空格。仅支持绝对路径。</li></ul>
<h3>卸载程序特殊选项</h3>
<ul><li>_?= 指定 $INSTDIR。这也会阻止卸载程序把它自己复制到临时文件夹再运行。这将可以使用 <a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.1.4"><font style="background-color: #3399ff" color="#ffffff">ExecWait</font></a> 来运行卸载程序并等待它完成。这个参数必须是最后一个参数并且不能带任何引号即使路径带有空格。</li></ul>
<h3>例子</h3><pre><div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">1</span>&nbsp;<span style="color: #000000">installer.exe&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">NCRC<br /></span><span style="color: #008080">2</span>&nbsp;<span style="color: #000000">installer.exe&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">S<br /></span><span style="color: #008080">3</span>&nbsp;<span style="color: #000000">installer.exe&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">D</span><span style="color: #000000">=</span><span style="color: #000000">C:\Program&nbsp;Files\NSIS<br /></span><span style="color: #008080">4</span>&nbsp;<span style="color: #000000">installer.exe&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">NCRC&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">S&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">D</span><span style="color: #000000">=</span><span style="color: #000000">C:\Program&nbsp;Files\NSIS<br /></span><span style="color: #008080">5</span>&nbsp;<span style="color: #000000">uninstaller.exe&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">S&nbsp;_</span><span style="color: #000000">?=</span><span style="color: #000000">C:\Program&nbsp;Files\NSIS</span></div></pre><pre># 静默卸载旧版本并等待它完成后才继续</pre><pre><div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">1</span>&nbsp;<span style="color: #000000">ExecWait&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">"$INSTDIR\uninstaller.exe"&nbsp;/S&nbsp;_?=$INSTDIR</span><span style="color: #000000">'</span></div><p><br />以上信息来自NSIS帮助。下面为实例代码：</p></pre>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #000000">!</span><span style="color: #000000">define&nbsp;APPLOCALPATH&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">Test.exe</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000"></span><span style="color: #000000">!</span><span style="color: #000000">define&nbsp;APPPATH&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$TEMP\${APPLOCALPATH}</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000">OutFile&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">Test&nbsp;${__DATE__}.exe</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000">Section&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">Silent&nbsp;MakeNSIS</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetOutPath&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$TEMP</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;File&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">r&nbsp;&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">install\*.*</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecWait&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">$TEMP\${APPLOCALPATH}&nbsp;/S&nbsp;/D=F:\Program&nbsp;Files\NSIS</span><span style="color: #000000">'</span><span style="color: #000000"><br /></span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Delete&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">$TEMP\${APPLOCALPATH}</span><span style="color: #000000">'</span><span style="color: #000000"><br /></span><span style="color: #008080">11</span>&nbsp;<span style="color: #000000">SectionEnd</span></div>
<p><br />&nbsp;</p> <img src ="http://www.cppblog.com/wanghaiguang/aggbug/176109.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-05-25 09:30 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/05/25/176109.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS 替换文件中的内容</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/05/04/173672.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Fri, 04 May 2012 10:12:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/05/04/173672.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/173672.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/05/04/173672.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/173672.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/173672.html</trackback:ping><description><![CDATA[Textreplace插件的使用：<br /><br />
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">1</span>&nbsp;<span style="color: #000000">!</span><span style="color: #000000">include&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">TextReplace.nsh</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">2</span>&nbsp;<span style="color: #000000"><br /></span><span style="color: #008080">3</span>&nbsp;<span style="color: #000000">${textreplace::ReplaceInFile}&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">c:\1.txt</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">c:\1.txt</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">%Install%</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">替换的内容</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">/S=1</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;$</span><span style="color: #000000">4</span><span style="color: #000000"><br /></span><span style="color: #008080">4</span>&nbsp;<span style="color: #000000">${textreplace::FreeReadBuffer}&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$4</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">5</span>&nbsp;<span style="color: #000000">${textreplace::Unload}</span></div> <img src ="http://www.cppblog.com/wanghaiguang/aggbug/173672.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-05-04 18:12 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/05/04/173672.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS修改创建文件夹读写权限</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/05/04/173655.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Fri, 04 May 2012 05:16:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/05/04/173655.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/173655.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/05/04/173655.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/173655.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/173655.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp; 在域环境下，有时受限账户对文件夹需要读、写操作权限，下面为修改文件夹访问权限代码：<br />&nbsp; 
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;ReadINIStr&nbsp;$</span><span style="color: #000000">1</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$EXEDIR\Test.ini</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">Directory</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">DirectoryName</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;ReadINIStr&nbsp;$</span><span style="color: #000000">2</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$EXEDIR\Test.ini</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">Directory</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">DriverDirectoryName</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;ReadEnvStr&nbsp;$</span><span style="color: #000000">3</span><span style="color: #000000">&nbsp;ALLUSERSPROFILE<br /></span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;CreateDirectory&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$3\$1</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;CreateDirectory&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$3\$2</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;;Make&nbsp;the&nbsp;directory&nbsp;read&nbsp;write&nbsp;accessible&nbsp;by&nbsp;everyone<br /></span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;AccessControl::GrantOnFile&nbsp;\<br /></span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$3\$1</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">everyone</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">GenericRead&nbsp;+&nbsp;GenericWrite</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #000000"><br /></span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;AccessControl::GrantOnFile&nbsp;\<br /></span><span style="color: #008080">11</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$3\$2</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">everyone</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">GenericRead&nbsp;+&nbsp;GenericWrite</span><span style="color: #000000">"</span></div>&nbsp;&nbsp;&nbsp; 在XP64位系统下，如果将提升权限的操作放到禁止重定向下面，修改文件夹权限会失败。如果对C:\WINDOWS\System32下面的配置文件进行修改，则必须放到禁止重定向下面修改。否则修改的将是C:\WINDOWS\SysWOW64下的配置文件。<br /> <img src ="http://www.cppblog.com/wanghaiguang/aggbug/173655.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-05-04 13:16 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/05/04/173655.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS常用路径</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/05/03/173593.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Thu, 03 May 2012 09:30:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/05/03/173593.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/173593.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/05/03/173593.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/173593.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/173593.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: $INSTDIR<br><br>安装目录 ($INSTDIR 可以使用 StrCpy、 ReadRegStr、 ReadINIStr 等等来更改。例如在 .onInit 函数里可以用来做高级的检测安装定位)。<br><br>注意在卸载程序代码里，$INSTDIR 为卸载程序所在的目录而不是在安装程序里所指定的目录。例如， 如果你把卸载程序放在 $WINDIR 里并且用户没有移动它，那么在卸载程序里 $INSTDIR 就等于 $WINDIR。如果你要把卸载程序放到另外的位置，那么你应该先把安装程序的 $INSTDIR 值写入注册表或者其它容易保存的地方，然后在卸载程序里读取该值并赋值给卸载程序里的 $INSTDIR。<br><br>&nbsp;&nbsp;<a href='http://www.cppblog.com/wanghaiguang/archive/2012/05/03/173593.html'>阅读全文</a><img src ="http://www.cppblog.com/wanghaiguang/aggbug/173593.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-05-03 17:30 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/05/03/173593.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何在NSIS中执行BAT文件</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/04/12/171070.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Thu, 12 Apr 2012 05:00:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/04/12/171070.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/171070.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/04/12/171070.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/171070.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/171070.html</trackback:ping><description><![CDATA[<span style="font-size: 14pt">本文转自：<a href="http://www.cppblog.com/humanchao/archive/2008/07/23/56962.html">http://www.cppblog.com/humanchao/archive/2008/07/23/56962.html</a><br /><br />如果BAT不带参数，脚本内容如下：<br /><br />SetOutPath '$INSTDIR'<br />ExecWait '$INSTDIR\A.bat'<br /><br />如果BAT需要参数时，要把带参数的命令写入另外一个新的BAT中，执行新BAT：<br /><br />B.bat内容：<br />CALL A.bat install<br /><br />NSIS 脚本：<br />SetOutPath '$INSTDIR'<br />ExecWait '$INSTDIR\B.bat'<br /></span> <img src ="http://www.cppblog.com/wanghaiguang/aggbug/171070.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-04-12 13:00 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/04/12/171070.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS获取当前系统版本</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/04/11/170937.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Wed, 11 Apr 2012 09:11:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/04/11/170937.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/170937.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/04/11/170937.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/170937.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/170937.html</trackback:ping><description><![CDATA[本文转自：<a href="http://www.flighty.cn/html/bushu/20110322_114.html">http://www.flighty.cn/html/bushu/20110322_114.html</a><br /><br />
<p>最新的WinVer.nsh下载：<br />http://nsis.sourceforge.net/Include/WinVer.nsh（下载后置于\NSIS\Inclued中）</p>
<p>AtLeastWin&lt;version&gt; 检测是否高于指定版本<br />IsWin&lt;version&gt; 检测指定版本（唯一限定版本）<br />AtMostWin&lt;version&gt; 检测是否低于指定版本</p>
<p>&lt;version&gt; 允许的值：<br />95、98、ME、NT4、2000、XP、2003、Vista、2008、7、2008R2</p>
<p>示例1：</p>
<div class="codeText">
<div class="codeHead"><span style="cursor: pointer" id="hit_2430" class="zhedie">折叠</span><span style="display: none; cursor: pointer" id="hit2_2430" class="zhedie">展开</span><span class="lantxt">NSIS 代码 
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #000000">!</span><span style="color: #000000">include&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">MUI.nsh</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000"></span><span style="color: #000000">!</span><span style="color: #000000">include&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">WinVer.nsh</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000"></span><span style="color: #000000">!</span><span style="color: #000000">insertmacro&nbsp;MUI_LANGUAGE&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">simpchinese</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000">Section&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000">${If}&nbsp;${AtLeastWinVista}&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;MessageBox&nbsp;MB_OK&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">系统为&nbsp;Vista&nbsp;或&nbsp;Vista&nbsp;以上系统！</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000">${EndIf}&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000">${If}&nbsp;${IsWin2000}&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">11</span>&nbsp;<span style="color: #000000">${OrIf}&nbsp;${IsWinXP}&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">12</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;MessageBox&nbsp;MB_OK&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">系统为&nbsp;2000&nbsp;或&nbsp;XP！</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">13</span>&nbsp;<span style="color: #000000">${EndIf}&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">14</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">15</span>&nbsp;<span style="color: #000000">${If}&nbsp;${AtMostWinXP}&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">16</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;MessageBox&nbsp;MB_OK&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">系统版本为&nbsp;XP&nbsp;或更低版本的系统！</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">17</span>&nbsp;<span style="color: #000000">${EndIf}<br /></span><span style="color: #008080">18</span>&nbsp;<span style="color: #000000">SectionEnd&nbsp;&nbsp;&nbsp;&nbsp;</span></div><br /></span></div>
<div id="code_2430"></div></div>
<p>示例2：</p>
<div class="codeText">
<div class="codeHead"><span style="cursor: pointer" id="hit_7734" class="zhedie">折叠</span><span style="display: none; cursor: pointer" id="hit2_7734" class="zhedie">展开</span><span class="lantxt">NSIS 代码
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #000000">!</span><span style="color: #000000">include&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">MUI.nsh</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000"></span><span style="color: #000000">!</span><span style="color: #000000">include&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">WinVer.nsh</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000"></span><span style="color: #000000">!</span><span style="color: #000000">insertmacro&nbsp;MUI_LANGUAGE&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">simpchinese</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000">Section&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000">${Unless}&nbsp;${ISWinXP}&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #000000">MessageBox&nbsp;MB_OK&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">本程序只能安装在&nbsp;Windows&nbsp;XP&nbsp;系统上！</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000">Abort&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #000000">${EndIf}&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000">SectionEnd&nbsp;</span></div></span></div>
<div id="code_7734"></div></div> <img src ="http://www.cppblog.com/wanghaiguang/aggbug/170937.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-04-11 17:11 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/04/11/170937.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS，产生随机数</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/04/06/170286.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Fri, 06 Apr 2012 09:13:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/04/06/170286.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/170286.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/04/06/170286.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/170286.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/170286.html</trackback:ping><description><![CDATA[<div>使用插件：<a href="http://nsis.sourceforge.net/NsRandom_plug-in">http://nsis.sourceforge.net/NsRandom_plug-in</a><br /><br />转自：<a href="http://www.dreams8.com/thread-11726-1-1.html">http://www.dreams8.com/thread-11726-1-1.html</a>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #000000">Function&nbsp;Random<br /></span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000">Exch&nbsp;$</span><span style="color: #000000">0</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000">Push&nbsp;$</span><span style="color: #000000">1</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000">System::Call&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">kernel32::QueryPerformanceCounter(*l.r1)</span><span style="color: #000000">'</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000">System::Int64Op&nbsp;$</span><span style="color: #000000">1</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">%</span><span style="color: #000000">&nbsp;$</span><span style="color: #000000">0</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000">Pop&nbsp;$</span><span style="color: #000000">0</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #000000">Pop&nbsp;$</span><span style="color: #000000">1</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000">Exch&nbsp;$</span><span style="color: #000000">0</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #000000">FunctionEnd<br /></span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000"><br /></span><span style="color: #008080">11</span>&nbsp;<span style="color: #000000">Push&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">100</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;<br /></span><span style="color: #008080">12</span>&nbsp;<span style="color: #000000">Call&nbsp;Random<br /></span><span style="color: #008080">13</span>&nbsp;<span style="color: #000000">Pop&nbsp;$</span><span style="color: #000000">0</span></div><br /><br /></div> <img src ="http://www.cppblog.com/wanghaiguang/aggbug/170286.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-04-06 17:13 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/04/06/170286.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS 获取硬盘序列号 </title><link>http://www.cppblog.com/wanghaiguang/archive/2012/04/06/170284.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Fri, 06 Apr 2012 09:10:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/04/06/170284.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/170284.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/04/06/170284.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/170284.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/170284.html</trackback:ping><description><![CDATA[&nbsp;转自：<a href="http://www.cppblog.com/huangyi5209/articles/143171.html">http://www.cppblog.com/huangyi5209/articles/143171.html</a>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #000000">!</span><span style="color: #000000">include&nbsp;MUI.nsh<br /></span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000">Function&nbsp;GetDiskVolumeSerialNumber<br /></span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000"></span><span style="color: #000000">!</span><span style="color: #000000">define&nbsp;GetVolumeInformation&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">Kernel32::GetVolumeInformation(t,t,i,*i,*i,*i,t,i)&nbsp;i</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000">System::Call&nbsp;</span><span style="color: #000000">'</span><span style="color: #000000">${GetVolumeInformation}("$0",,${NSIS_MAX_STRLEN},.r0,,,,${NSIS_MAX_STRLEN})</span><span style="color: #000000">'</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000">FunctionEnd<br /></span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000">Section<br /></span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #000000">StrCpy&nbsp;$</span><span style="color: #000000">0</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">C:\</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000">Call&nbsp;GetDiskVolumeSerialNumber<br /></span><span style="color: #008080">11</span>&nbsp;<span style="color: #000000">IntFmt&nbsp;$</span><span style="color: #000000">0</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">%08X</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;$</span><span style="color: #000000">0</span><span style="color: #000000"><br /></span><span style="color: #008080">12</span>&nbsp;<span style="color: #000000">MessageBox&nbsp;MB_OK&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">$0</span><span style="color: #000000">"</span><span style="color: #000000"><br /></span><span style="color: #008080">13</span>&nbsp;<span style="color: #000000">SectionEnd</span></div><br /><br /> <img src ="http://www.cppblog.com/wanghaiguang/aggbug/170284.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-04-06 17:10 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/04/06/170284.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NSIS安装包64位系统调用注册表函数</title><link>http://www.cppblog.com/wanghaiguang/archive/2012/03/08/167385.html</link><dc:creator>王海光</dc:creator><author>王海光</author><pubDate>Thu, 08 Mar 2012 04:51:00 GMT</pubDate><guid>http://www.cppblog.com/wanghaiguang/archive/2012/03/08/167385.html</guid><wfw:comment>http://www.cppblog.com/wanghaiguang/comments/167385.html</wfw:comment><comments>http://www.cppblog.com/wanghaiguang/archive/2012/03/08/167385.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wanghaiguang/comments/commentRss/167385.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wanghaiguang/services/trackbacks/167385.html</trackback:ping><description><![CDATA[<div><span style="font-family: Verdana">转自：</span><a href="http://blog.csdn.net/blueblood7/article/details/7193573"><span style="font-family: Verdana">http://blog.csdn.net/blueblood7/article/details/7193573</span></a><br /><br /><br /><span style="font-family: Verdana; font-size: 18pt">用 NSIS制作64位安装包 步骤</span><br /><br />
<p class="article_content"><span style="font-family: Verdana; font-size: 18px">1、在安装脚本的开始处定义 LIBRARY_X64。</span></p>
<p class="article_content"><span style="font-family: Verdana">!include "MUI.nsh"</span><br /><span style="font-family: Verdana">!include "Library.nsh"</span></p>
<p class="article_content"><span style="font-family: Verdana">;如果做32位安装包就把下句注释。</span><br /><span style="font-family: Verdana">!define LIBRARY_X64</span></p>
<p class="article_content">&nbsp;</p>
<p class="article_content"><span style="font-family: Verdana; font-size: 18px">2、注册COM组件，需包含Library.nsh，用宏InstallLib/UnInstallLib 代替RegDLL/UnRegDLL。</span></p>
<p class="article_content"><span style="font-family: Verdana">;RegDLL "$SYSDIR\ComName.dll"</span><br /><span style="font-family: Verdana">!insertmacro InstallLib REGDLL NOTSHARED REBOOT_NOTPROTECTED "LocalPath\ComName.dll" "$SYSDIR\ComName.dll" $SYSDIR</span></p>
<p class="article_content"><span style="font-family: Verdana">;UnRegDLL "$SYSDIR\ComName.dll"</span><br /><span style="font-family: Verdana">!insertmacro UnInstallLib REGDLL NOTSHARED REBOOT_NOTPROTECTED "$SYSDIR\ComName.dll"</span></p>
<p class="article_content">&nbsp;</p>
<p class="article_content"><span style="font-family: Verdana; color: red; font-size: 18px">3、在调用涉及注册表的函数前用 SetRegView 64，后用 SetRegView lastused。</span></p>
<p class="article_content"><span style="font-family: Verdana">!ifdef &nbsp;LIBRARY_X64</span><br /><span style="font-family: Verdana">&nbsp;SetRegView 64</span><br /><span style="font-family: Verdana">!endif</span></p>
<p class="article_content"><span style="font-family: Verdana">&nbsp;WriteRegStr ...</span><br /><span style="font-family: Verdana">&nbsp;WriteRegStr ...</span><br /><span style="font-family: Verdana">&nbsp;WriteRegStr ...</span></p>
<p class="article_content"><span style="font-family: Verdana">!ifdef &nbsp;LIBRARY_X64</span><br /><span style="font-family: Verdana">&nbsp;SetRegView lastused</span><br /><span style="font-family: Verdana">!endif&nbsp;</span><br /><br /><span style="font-family: Verdana">SetRegView用户手册：</span><br /><span style="font-family: Verdana">在 Windows x64 上共有2种查看方式。一种用于 32-bit 应用程序，另一种用于 x64 应用程序。默认情况下，32-bit 应用程序运行在 x64 系统的 WOW64 模式下时，只允许使用 32-bit 查看方式。使用 </span><code><span style="font-family: Verdana">SetRegView 64</span></code><span style="font-family: Verdana"> 将允许安装程序在 x64 中访问注册表键值。 </span></p>
<p><span style="font-family: Verdana">它将影响 </span><br /><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.3"><span style="font-family: Verdana">DeleteRegKey</span></a><span style="font-family: Verdana">,</span><br /><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.4"><span style="font-family: Verdana">DeleteRegValue</span></a><span style="font-family: Verdana">, </span><br /><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.5"><span style="font-family: Verdana">EnumRegKey</span></a><span style="font-family: Verdana">, </span><br /><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.6"><span style="font-family: Verdana">EnumRegValue</span></a><span style="font-family: Verdana">, </span><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.11"><br /><span style="font-family: Verdana">ReadRegDWORD</span></a><span style="font-family: Verdana">, </span><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.12"><br /><span style="font-family: Verdana">ReadRegStr</span></a><span style="font-family: Verdana">, </span><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.14"><br /><span style="font-family: Verdana">WriteRegBin</span></a><span style="font-family: Verdana">, </span><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.15"><br /><span style="font-family: Verdana">WriteRegDWORD</span></a><span style="font-family: Verdana">, </span><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.16"><br /><span style="font-family: Verdana">WriteRegStr</span></a><span style="font-family: Verdana">,</span><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.17"><br /><span style="font-family: Verdana">WriteRegExpandStr</span></a><span style="font-family: Verdana">。</span></p>
<p><span style="font-family: Verdana">它不会影响 </span><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.8.html#4.8.1.22"><span style="font-family: Verdana">InstallDirRegKey</span></a><span style="font-family: Verdana">。另外，在函数 </span><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.7.html#4.7.2.1.2"><span style="font-family: Verdana">.onInit</span></a><span style="font-family: Verdana"> 中也可使用 </span><a href="mk:@MSITStore:C:\Program%20Files\NSIS\NSIS.chm::/Section4.9.html#4.9.2.12"><span style="font-family: Verdana">ReadRegStr</span></a><span style="font-family: Verdana"> 读取注册表。</span><br /></p><pre><span style="font-family: Verdana">SetRegView 32
ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion ProgramFilesDir
DetailPrint $0 # prints C:\Program Files (x86)
SetRegView 64
ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion ProgramFilesDir
DetailPrint $0 # prints C:\Program Files
</span></pre><pre><span style="font-family: Verdana">Function .onInit
  SetRegView 64
  ReadRegStr $INSTDIR HKLM Software\NSIS ""
  SetRegView 32
FunctionEnd</span></pre>
<p class="article_content"><span style="font-family: Verdana; font-size: 18px">4、在调用涉及目标机器上系统目录（即$SYSDIR）的函数前用 ${DisableX64FSRedirection}。</span></p>
<p class="article_content"><span style="font-family: Verdana">在安装包的第一个Section中调用一次即可。</span><br /><span style="font-family: Verdana">!ifdef &nbsp;LIBRARY_X64</span><br /><span style="font-family: Verdana">&nbsp;${DisableX64FSRedirection}</span><br /><span style="font-family: Verdana">!endif&nbsp;</span></p>
<p class="article_content">&nbsp;</p>
<p class="article_content"><span style="font-family: Verdana; font-size: 18px">5、在64位系统上 $PROGRAMFILES64 表示&#8220;Program Files&#8221;, $PROGRAMFILES 表示 &#8220;Program Files (x86)&#8221;。</span></p>
<p class="article_content"><span style="font-family: Verdana">可以在安装脚本的开始处定义一个常量，</span><br /><span style="font-family: Verdana">!ifdef LIBRARY_X64</span><br /><span style="font-family: Verdana">!define PROGRAM_FILES_MAP &nbsp;$PROGRAMFILES64</span><br /><span style="font-family: Verdana">!else</span><br /><span style="font-family: Verdana">!define PROGRAM_FILES_MAP &nbsp;$PROGRAMFILES</span><br /><span style="font-family: Verdana">!endif</span><br /><span style="font-family: Verdana">以后直接用 ${PROGRAM_FILES_MAP} 代替 $PROGRAMFILES。</span></p>
<p class="article_content">&nbsp;</p>
<p class="article_content"><span style="font-family: Verdana; font-size: 18px">6、在.onInit 和 un.onInit 中判断一下，如果安装包是在32位操作系统上运行，则停止安装。</span></p>
<p class="article_content"><span style="font-family: Verdana">可创建一个宏，然后在需要的地方插入。</span><br /><span style="font-family: Verdana">!macro TIP_WHEN_AMD64_INSTALLER_RUNAT_X86</span><br /><span style="font-family: Verdana">&nbsp;!ifdef LIBRARY_X64</span><br /><span style="font-family: Verdana">&nbsp;&nbsp;${If} ${RunningX64}</span><br /><span style="font-family: Verdana">&nbsp;&nbsp;${else}</span><br /><span style="font-family: Verdana">&nbsp;&nbsp; &nbsp;&nbsp;MessageBox MB_OK|MB_ICONINFORMATION "请在64位操作系统下运行。"</span><br /><span style="font-family: Verdana">&nbsp;&nbsp;&nbsp;Abort</span><br /><span style="font-family: Verdana">&nbsp;&nbsp;${EndIf}</span><br /><span style="font-family: Verdana">&nbsp;!endif</span><br /><span style="font-family: Verdana">!macroend</span></p>
<p class="article_content"><span style="font-family: Verdana">Function .onInit</span><br /><span style="font-family: Verdana">&nbsp;!insertmacro TIP_WHEN_AMD64_INSTALLER_RUNAT_X86</span><br /><span style="font-family: Verdana">&nbsp;SetShellVarContext all&nbsp;&nbsp;;安装到所有用户下，current 表示安装到当前用户下, all 表示所有用户下。</span><br /><span style="font-family: Verdana">FunctionEnd</span></p>
<p class="article_content"><span style="font-family: Verdana">Function un.onInit</span><br /><span style="font-family: Verdana">&nbsp;!insertmacro TIP_WHEN_AMD64_INSTALLER_RUNAT_X86</span><br /><span style="font-family: Verdana">&nbsp;SetShellVarContext all</span><br /><span style="font-family: Verdana">FunctionEnd</span></p>
<p class="article_content">&nbsp;</p>
<p class="article_content"><span style="font-size: 18px">备注：<br />1、在 NSIS 中的条件编译是 !开头，不是 #开头，如!ifdef。<br />2、对COM组件，我认为应该是使用 NOTSHARED 方式注册。<br />3、可以做个批处理文件，一次性生成32位/64位的安装包。<br />&nbsp;如 x.bat<br />&nbsp;rem "记得要把安装脚本中的 !define LIBRARY_X64 注释掉，否则不能生成32位安装包。"<br />&nbsp;makensis .\myinstaller.nsi<br />&nbsp;makensis /DLIBRARY_X64 .\myinstaller.nsi<br />&nbsp;pause<br /></span>&nbsp;<br /></p></div><img src ="http://www.cppblog.com/wanghaiguang/aggbug/167385.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wanghaiguang/" target="_blank">王海光</a> 2012-03-08 12:51 <a href="http://www.cppblog.com/wanghaiguang/archive/2012/03/08/167385.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>