楼主: 天意

NSIS练习之作-精选手写字体(附NSIS教程电子书)

  [复制链接]
发表于 2011-10-15 03:16:23 | 显示全部楼层
可以看看,有实用效果没
发表于 2011-10-21 15:52:34 | 显示全部楼层
这个得收藏了,有时间学习一下
发表于 2011-10-21 20:40:46 | 显示全部楼层
没用过·······谢谢分享········
发表于 2011-11-18 03:05:55 | 显示全部楼层
支持天意,谢谢分享
发表于 2011-11-19 02:01:42 | 显示全部楼层
学无止境  呵呵
发表于 2011-11-20 15:41:25 | 显示全部楼层
一定是好东西!
发表于 2012-8-23 14:06:49 | 显示全部楼层
天意老师 能不能给我 天意U盘维护系统 3.0网络增强版 的源代码啊
 楼主| 发表于 2012-8-23 15:24:00 | 显示全部楼层
_ㄨ.Ian 发表于 2012-8-23 14:06
天意老师 能不能给我 天意U盘维护系统 3.0网络增强版 的源代码啊
  1. ##这是一个可以安装fba包的u盘启动安装器源码,
  2. ##资源包src里面的ty.fba是一个空文件,请用自己的fba包替换。
  3. ##=====================================
  4. ##本源码由teasiu@163.com创建。请保留此信息。
  5. ##=====================================
  6. !define NAME "天意U盘维护系统"
  7. !define DISTRO "天意U盘维护系统"
  8. !define FILENAME "天意U盘维护系统"
  9. !define VERSION "网络增强V2012版"
  10. !define MUI_ICON "AUTORUN.ICO"
  11. RequestExecutionLevel highest
  12. SetCompressor LZMA
  13. CRCCheck On
  14. XPStyle on
  15. ShowInstDetails show
  16. BrandingText "天意U盘维护系统安装器"
  17. CompletedText "安装结束,欢迎使用和收藏本工具! "
  18. InstallButtonText "安 装"

  19. Name "${NAME} ${VERSION}"
  20. OutFile "${FILENAME} ${VERSION}.exe"

  21. !include "nsDialogs.nsh"
  22. !include "MUI2.nsh"
  23. !include "FileFunc.nsh"
  24. !include "WordFunc.nsh" ;DriveList
  25. ; Interface settings
  26. !define MUI_HEADERIMAGE
  27. !define MUI_HEADERIMAGE_BITMAP "usb-logo.bmp"
  28. !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
  29. !define MUI_HEADERIMAGE_RIGHT

  30. ; Drive page
  31. Var Dialog
  32. Var DestDriveTxt
  33. Var DestDrive
  34. Var DestDisk
  35. Var LabelDrivePageText
  36. Var LabelDriveSelect
  37. Var AllDriveOption
  38. Var DisplayAll
  39. Var Format
  40. Var FormatMe
  41. Var Hddmode
  42. Var Zipmode
  43. Var HddmodeMe
  44. Var ZipmodeMe
  45. Var Warning
  46. Var Soft
  47. Var Link
  48. Var Links
  49. Var Image
  50. Var hImage
  51. Var size


  52. #Page custom SetCustom LeaveCustom
  53. Page custom drivePage


  54. !define MUI_INSTFILESPAGE_COLORS "00FF00 000000"
  55. ; Instfiles page
  56. !define MUI_TEXT_INSTALLING_TITLE $(Install_Title)
  57. !define MUI_TEXT_INSTALLING_SUBTITLE $(Install_SubTitle)
  58. !define MUI_TEXT_FINISH_SUBTITLE $(Install_Finish_Sucess)
  59. !insertmacro MUI_PAGE_INSTFILES

  60. ; Language files
  61. !insertmacro MUI_LANGUAGE "SimpChinese"
  62. LangString DrivePage_Title ${LANG_SIMPCHINESE} "【天意作品】天意U盘维护系统安装器"
  63. LangString DrivePage_Title2 ${LANG_SIMPCHINESE} "先插入您的U盘或移动硬盘,然后再打开本软件进行安装。"
  64. LangString DrivePage_Text ${LANG_SIMPCHINESE} "本工具将使您的USB设备完美启动。"
  65. LangString DrivePage_Input ${LANG_SIMPCHINESE} "第一步:点击下拉菜单选择磁盘"
  66. LangString Soft_Text ${LANG_SIMPCHINESE} "第二步:选择USB设备启动引导模式。必选。"
  67. LangString WarningPage_Text ${LANG_SIMPCHINESE} "注意:请确保U盘资料已备份。原资料将被完全覆写并不可恢复!"
  68. LangString Install_Title ${LANG_SIMPCHINESE} "安装中 ${DISTRO}"
  69. LangString Install_SubTitle ${LANG_SIMPCHINESE} "请稍候 ${NAME} 安装 ${DISTRO} 到 $DestDisk"
  70. LangString Install_Finish_Sucess ${LANG_SIMPCHINESE} "$\t ${NAME} 已经完成安装${DISTRO}到$DestDisk"

  71. Function .onInit
  72. InitPluginsDir
  73. File /oname=$PLUGINSDIR\ad.bmp "ad.bmp" ; 嵌入bmp位图以便后面调用
  74. FunctionEnd

  75. Function drivePage
  76. !insertmacro MUI_HEADER_TEXT $(DrivePage_Title) $(DrivePage_Title2)
  77. nsDialogs::Create 1018
  78. Pop $Dialog
  79. ${If} $DestDrive == ""
  80. GetDlgItem $6 $HWNDPARENT 1 ; Get next control handle
  81. EnableWindow $6 0 ; disable next
  82. ${EndIf}
  83. ;创建bmp位图
  84. ${NSD_CreateBitmap} 78% 0 20% 100% ""
  85. Pop $Image
  86. ${NSD_SetImage} $Image $PLUGINSDIR\ad.bmp $hImage

  87. ${NSD_CreateLabel} 0 0 70% 30 $(DrivePage_Text)
  88. Pop $LabelDrivePageText
  89. ${NSD_CreateLabel} 0 20 70% 25 $(DrivePage_Input)
  90. Pop $LabelDriveSelect
  91. SetCtlColors $LabelDriveSelect /Branding 0000BD

  92. ${NSD_CreateCheckBox} 33% 43 45% 14 "显示全部驱动盘 (慎用)"
  93. Pop $AllDriveOption
  94. ${NSD_OnClick} $AllDriveOption ListAllDrives
  95. ${NSD_CreateDroplist} 0 40 30% 25 ""
  96. Pop $DestDriveTxt
  97. Call ListAllDrives
  98. ${NSD_OnChange} $DestDriveTxt db_select.onchange
  99. ${If} $DestDrive != ""
  100. ${NSD_CB_SelectString} $DestDriveTxt $DestDrive
  101. ${EndIf}

  102. ; Add Help Link
  103. ${NSD_CreateLink} 84% 192 15% 14 "软件更新" ; 创建一个链接地址 84%代表位置横坐标,190代表位置纵坐标,15%代表内容横坐标,14代表内容纵坐标
  104. Pop $Link
  105. ${NSD_OnClick} $Link onClickMyLink
  106. ; Format Drive Option
  107. ${NSD_CreateButton} 33% 64 32% 22 "(可选)格式化回收空间"
  108. Pop $Format
  109. ${NSD_OnClick} $Format FormatIt
  110. ; Soft Label
  111. ${NSD_CreateLabel} 0 100 70% 15 $(Soft_Text) ;软件内容 0代表位置横坐标,70代表位置纵坐标,70%代表内容横坐标,15代表内容纵坐标
  112. Pop $Soft
  113. SetCtlColors $Soft /Branding 0000BD

  114. ; 磁盘启动模式选项
  115. ${NSD_CreateCheckBox} 0 120 36% 15 "HDD启动模式."
  116. Pop $Hddmode
  117. ${NSD_Check} $Hddmode
  118. ${NSD_OnClick} $Hddmode HddmodeIt

  119. ${NSD_CreateCheckBox} 38% 120 36% 15 "ZIP启动模式."
  120. Pop $Zipmode
  121. ${NSD_OnClick} $Zipmode ZipmodeIt

  122. ; Warning Label
  123. ${NSD_CreateLabel} 0 190 80% 14 $(WarningPage_Text)
  124. Pop $Warning
  125. EnableWindow $Format 0
  126. EnableWindow $Hddmode 0
  127. EnableWindow $Zipmode 0
  128. ShowWindow $Warning 0
  129. GetDlgItem $6 $HWNDPARENT 3
  130. ShowWindow $6 0 ; Disable Back
  131. nsDialogs::Show
  132. ${NSD_FreeImage} $hImage
  133. FunctionEnd

  134. Function ListAllDrives ; Set to Display All Drives
  135. SendMessage $DestDriveTxt ${CB_RESETCONTENT} 0 0
  136. ${NSD_GetState} $AllDriveOption $DisplayAll
  137. ${If} $DisplayAll == ${BST_CHECKED}
  138. ${NSD_Check} $AllDriveOption
  139. ${NSD_SetText} $AllDriveOption "现在显示所有驱动盘 (小心)"
  140. ${GetDrives} "ALL" DrivesList ; All Drives Listed
  141. ${ElseIf} $DisplayAll == ${BST_UNCHECKED}
  142. ${NSD_Uncheck} $AllDriveOption
  143. ${NSD_SetText} $AllDriveOption "显示所有驱动盘 (慎用)"
  144. ${GetDrives} "FDD" DrivesList ; FDD+HDD reduce to FDD for removable media only
  145. ${EndIf}
  146. FunctionEnd

  147. Function onClickMyLink
  148. Pop $Links ; pop something to prevent corruption
  149. ExecShell "open" "http://www.winpe.cc"
  150. FunctionEnd


  151. Function db_select.onchange
  152. Pop $DestDriveTxt
  153. ${NSD_GetText} $DestDriveTxt $0
  154. StrCpy $DestDrive "$0"
  155. StrCpy $DestDisk "$DestDrive" -1
  156. GetDlgItem $6 $HWNDPARENT 1 ; Get "Next" control handle
  157. EnableWindow $6 1 ; enable "Next" control
  158. EnableWindow $Format 1
  159. EnableWindow $Hddmode 1
  160. EnableWindow $Zipmode 1
  161. ShowWindow $Warning 1
  162. SetCtlColors $Warning /Branding FF0000
  163. Call HddmodeIt
  164. Call ZipmodeIt
  165. FunctionEnd

  166. Function DrivesList ; 磁盘列表,表示形式为盘符CDE等
  167. SendMessage $DestDriveTxt ${CB_ADDSTRING} 0 "STR:$9"
  168. Push 1
  169. FunctionEnd

  170. ;下面2个方程的意思是:无论用户怎么点击,都必须要选中一个
  171. Function HddmodeIt
  172. ${NSD_GetState} $Hddmode $HddmodeMe

  173. ${If} $HddmodeMe == ${BST_CHECKED}
  174. ${NSD_Check} $Hddmode
  175. StrCpy $HddmodeMe "Yes"
  176. ${NSD_SetText} $Hddmode "(已选)HDD启动模式"
  177. ${NSD_Uncheck} $Zipmode
  178. StrCpy $ZipmodeMe "No"
  179. ${NSD_SetText} $Zipmode "ZIP启动模式"

  180. ${ElseIf} $HddmodeMe == ${BST_UNCHECKED}
  181. ${NSD_Uncheck} $Hddmode
  182. StrCpy $HddmodeMe "No"
  183. ${NSD_SetText} $Hddmode "HDD启动模式"
  184. ${NSD_Check} $Zipmode
  185. StrCpy $ZipmodeMe "Yes"
  186. ${NSD_SetText} $Zipmode "(已选)ZIP启动模式"
  187. ${EndIf}
  188. FunctionEnd

  189. Function ZipmodeIt ; Set Format Option
  190. ${NSD_GetState} $Zipmode $ZipmodeMe
  191. ${If} $ZipmodeMe == ${BST_CHECKED}
  192. ${NSD_Check} $Zipmode
  193. StrCpy $ZipmodeMe "Yes"
  194. ${NSD_SetText} $Zipmode "(已选)ZIP启动模式"
  195. ${NSD_Uncheck} $Hddmode
  196. StrCpy $HddmodeMe "No"
  197. ${NSD_SetText} $Hddmode "HDD启动模式"
  198. ${ElseIf} $ZipmodeMe == ${BST_UNCHECKED}
  199. ${NSD_Uncheck} $Zipmode
  200. StrCpy $ZipmodeMe "No"
  201. ${NSD_SetText} $Zipmode "ZIP启动模式"
  202. ${NSD_Check} $Hddmode
  203. StrCpy $HddmodeMe "Yes"
  204. ${NSD_SetText} $Hddmode "(已选)HDD启动模式"
  205. ${EndIf}
  206. FunctionEnd

  207. Function FormatIt ; Set Format Option这里增加询问框,更加人性化
  208. Pop $FormatMe
  209. MessageBox MB_YESNO "格式化U盘可以取回全部空间,继续吗?" IDYES true IDNO false
  210. true:
  211. Goto next
  212. false:
  213. MessageBox MB_OK|MB_ICONSTOP "不格式化,退出"
  214. Abort
  215. next:
  216. MessageBox MB_YESNO "真的格式化吗?(请确保您的U盘资料已经备份,格式化将擦除U盘资料且不可恢复)" /SD IDYES IDNO false2
  217. Goto next2
  218. false2:
  219. MessageBox MB_OK|MB_ICONSTOP "不格式化,退出"
  220. Abort
  221. next2:
  222. InitPluginsDir
  223. File /oname=$PLUGINSDIR\fbinst.exe "src\fbinst.exe" ;调用一下src文件夹里面的fbinst.exe用于格式化
  224. nsExec::ExecToLog '"cmd" /c "echo y|$PLUGINSDIR\fbinst $DestDisk format --raw --force --fat32"'
  225. MessageBox MB_OK "格式化完成,恢复U盘全部空间。"
  226. FunctionEnd

  227. Function InstallEYes
  228. InitPluginsDir
  229. SetOutPath "$PLUGINSDIR"
  230. File /r "src\*.*" ;文件夹src里面必须包含2个文件,fbinst.exe和你的fba包,在这个例子里名字为ty.fba,下面要相对应名字
  231. ${GetSize} "$PLUGINSDIR" "/M=ty.fba /S=0M /G=0" $0 $1 $2
  232. StrCpy $size "$0"
  233. DetailPrint "fba包大小为$sizeMB"
  234. ${If} $HddmodeMe == "Yes"
  235. DetailPrint "创建HDD模式的引导和复制天意U盘维护系统到 $DestDisk, 请稍候"
  236. ;下面这段请根据您的fba包大小来填写UD扩展分区的大小extended ?m,UD主分区默认大小是8m,否则会出现安装错误。
  237. ;fba包目前使用fbinstool工具比较方便,假如你很掌握fbinst命令,也完全可以使用命令在这里创建fba包然后安装它,写起来比较复杂。
  238. nsExec::ExecToLog '"cmd" /c "echo y|$PLUGINSDIR\fbinst $DestDisk format --extended $sizeM --force --align --primary 8m --archive $PLUGINSDIR\ty.fba"'
  239. DetailPrint "天意U盘维护系统已经安装到$DestDisk的隐藏区占 $size MB + 8 MB"
  240. ${ElseIf} $ZipmodeMe == "Yes"
  241. DetailPrint "创建Zip模式的引导和复制天意U盘维护系统到 $DestDisk, 请稍候"
  242. nsExec::ExecToLog '"cmd" /c "echo y|$PLUGINSDIR\fbinst $DestDisk format --extended $sizeM --force --zip --align --primary 8m --archive $PLUGINSDIR\ty.fba"'
  243. DetailPrint "天意U盘维护系统zip模式已经安装到$DestDisk的隐藏区占 $size MB + 8 MB"
  244. ${EndIf}
  245. FunctionEnd

  246. Section "Install" main
  247. Call InstallEYes ;指令安装进程程式
  248. nsExec::ExecToLog '"cmd" /c "echo y|$PLUGINSDIR\fbinst $DestDisk pack"' ;安装完成后整理碎片
  249. SectionEnd
复制代码
发表于 2012-8-24 14:59:57 | 显示全部楼层
谢谢天意老师
发表于 2014-2-10 20:21:23 | 显示全部楼层
不错啊 谢谢老大分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表