; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "iQue聚乐部管理软件"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "iQue, Inc."
!define PRODUCT_WEB_SITE "http://www.iQue.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\ncproxy.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

!define DEVICE_NAME_CODE "Vid_1527&Pid_bcdb"
!define DEVICE_KEY "##?#USB#${DEVICE_NAME_CODE}"
!define DRIVER_CLASS_KEY "SYSTEM\CurrentControlSet\Control\Class\{36FC9E60-C465-11CF-8056-444553540000}"
!define DRIVER_ENUM_KEY "SYSTEM\CurrentControlSet\Enum\USB\${DEVICE_NAME_CODE}"
!define DRIVER_SERVICES_KEY "SYSTEM\CurrentControlSet\Services\iquenc"
!define DRIVER_ENUM_USBHUB_KEY "SYSTEM\CurrentControlSet\Enum\USB\ROOT_HUB"
!define DRIVER_DEVICECLASS_KEY "SYSTEM\CurrentControlSet\Control\DeviceClasses"
!define IQUE_SCLID "{b881af97-51a7-4bc1-9bc5-736e7497b93e}"
;"{9c37855e-3d67-487a-b70e-eb4ea357a969}"
!define AUTORUN_SCLID "{a5dcbf10-6530-11d2-901f-00c04fb951ed}"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "..\BMP\install.ico"
!define MUI_UNICON "..\BMP\uninstall.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP  "..\BMP\left1.bmp"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_HEADERIMAGE_BITMAP "..\BMP\head2.bmp"
!define MUI_FINISHPAGE_TEXT "${PRODUCT_NAME}${PRODUCT_VERSION}已经在您系统安装完成。\r\n单击[完成(F)]按钮关闭此向导。\r\n\r\n请重启您的游戏机！"
!define MUI_FINISHPAGE_TEXT_REBOOT "要完成${PRODUCT_NAME}${PRODUCT_VERSION}的安装，必须重启系统。\r\n\r\n请重启您的游戏机！"


;!define MUI_WELCOMEFININSHPAGE_BITMAP "..\BMP\left1.bmp"

;!define MUI_WELCOMEPAGE_TITLE "\r\n欢迎使用我！"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "..\license-zh.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
;!define MUI_FINISHPAGE_RUN "$INSTDIR\ncproxy.exe"
;!define MUI_FINISHPAGE_RUN_PARAMETERS "-p"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "SimpChinese"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "iQueNetCardSetup071010.exe"
InstallDir "$PROGRAMFILES\iQue聚乐部"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

; Functions

Function RegUSBDevice
  Exch $R0
  ;Begin Enum device and DeviceClass register
  StrCpy $2 0
loopEnumKey:
  EnumRegKey $3 HKLM $R0 $2
  StrCmp $3 "" afterEnumKey
  IntOp $2 $2 + 1
  ;找到usb_hub的设备编号
  ReadRegStr $4 HKLM "$R0\$3" "ParentIdPrefix"
  ;MessageBox MB_YESNO|MB_ICONQUESTION "Get ParentIdPrefix : $4$\n?"
  StrCmp $4 "" loopEnumKey
  ;已经找到了一个usb_hub ，然后我们开始给usb_hub上的端口注册驱动信息。usb_hub一般有可能被分为4个port，因此我们
  ;对每个port都作一次注册。
  IntOp $5 0 + 0
  
PortnumLess4:
  IntOp $5 $5 + 1
  ;MessageBox MB_YESNO|MB_ICONQUESTION "begin write enmu iquenc : ${DRIVER_ENUM_KEY}\$4&$5 $\n?"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_ENUM_KEY}\$4&$5" "Class" "USB"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_ENUM_KEY}\$4&$5" "ClassGUID" "{36FC9E60-C465-11CF-8056-444553540000}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_ENUM_KEY}\$4&$5" "Driver" "{36FC9E60-C465-11CF-8056-444553540000}\$1"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_ENUM_KEY}\$4&$5" "Mfg" "iQue"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_ENUM_KEY}\$4&$5" "Service" "iquenc"
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_ENUM_KEY}\$4&$5" "ConfigFlags" 0x00000000
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_ENUM_KEY}\$4&$5\Device Parameters" "SymbolicName" "\??\USB#${DEVICE_NAME_CODE}#$4&$5#${AUTORUN_SCLID}iquenc"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_ENUM_KEY}\$4&$5" "DeviceDesc" "iQue Net Card"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_ENUM_KEY}\$4&$5\Control" "ActiveService" "iquenc"
  ;WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_SERVICES_KEY}\Enum" "$2" "$3"
  ;MessageBox MB_YESNO|MB_ICONQUESTION "${DRIVER_SERVICES_KEY}\Enum  $2  $3$\n$\nMore?"
  ;给端口注册deviceClass信息
  ;MessageBox MB_YESNO|MB_ICONQUESTION "${DRIVER_DEVICECLASS_KEY}\${IQUE_SCLID}\${DEVICE_KEY}#$4&$5#${IQUE_SCLID}  $\n \\?\USB#${DEVICE_NAME_CODE}#$4&$5#${IQUE_SCLID} $\n?"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_DEVICECLASS_KEY}\${IQUE_SCLID}\${DEVICE_KEY}#$4&$5#${IQUE_SCLID}" "DeviceInstance" "USB\${DEVICE_NAME_CODE}\$4&$5"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_DEVICECLASS_KEY}\${IQUE_SCLID}\${DEVICE_KEY}#$4&$5#${IQUE_SCLID}\#" "SymbolicLink" "\\?\USB#${DEVICE_NAME_CODE}#$4&$5#${IQUE_SCLID}"
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_DEVICECLASS_KEY}\${IQUE_SCLID}\${DEVICE_KEY}#$4&$5#${IQUE_SCLID}\#\Control" "Linked" 0x00000000
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_DEVICECLASS_KEY}\${IQUE_SCLID}\${DEVICE_KEY}#$4&$5#${IQUE_SCLID}\Control" "ReferenceCount" 0x00000000
  ;MessageBox MB_YESNO|MB_ICONQUESTION "${DRIVER_DEVICECLASS_KEY}\${AUTORUN_SCLID}\${DEVICE_KEY}#$4&$5#${AUTORUN_SCLID}  $\n \\?\USB#${DEVICE_NAME_CODE}#$4&$5#${AUTORUN_SCLID} $\n?"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_DEVICECLASS_KEY}\${AUTORUN_SCLID}\${DEVICE_KEY}#$4&$5#${AUTORUN_SCLID}" "DeviceInstance" "USB\${DEVICE_NAME_CODE}\$4&$5"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_DEVICECLASS_KEY}\${AUTORUN_SCLID}\${DEVICE_KEY}#$4&$5#${AUTORUN_SCLID}\#" "SymbolicLink" "\\?\USB#${DEVICE_NAME_CODE}#$4&$5#${AUTORUN_SCLID}"
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_DEVICECLASS_KEY}\${AUTORUN_SCLID}\${DEVICE_KEY}#$4&$5#${AUTORUN_SCLID}\#\Control" "Linked" 0x00000000
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_DEVICECLASS_KEY}\${AUTORUN_SCLID}\${DEVICE_KEY}#$4&$5#${AUTORUN_SCLID}\Control" "ReferenceCount" 0x00000000

  IntCmp $5 4 PortnumIs4 PortnumLess4 PortnumMore4
PortnumIs4:
PortnumMore4:
  Goto loopEnumKey
  afterEnumKey:
  pop $R0
FunctionEnd
;  Functions end ------------


Section "MainSection" SEC01

  SetOutPath "$WINDIR\SYSTEM32\Drivers"
  SetOverwrite ifnewer
  File "..\usb_driver\iquenc.sys"
  SetOutPath "$WINDIR\inf"
  SetOverwrite ifnewer
  File "..\usb_driver\iquenc.inf"
  
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "..\license-zh.txt"
  File "..\license-en.txt"
  File "..\update.exe"
  File "..\BeginUpdate.exe"
  File "..\VERSION"
  File "..\SERVER"
  File "..\FreeImage.dll"
  File "..\tomp3.exe"
  File "..\ChangeRegisterSecurity.exe"

  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
  CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\iQue聚乐部管理软件.lnk" "$INSTDIR\iQue聚乐部管理软件.exe"
  
  CreateDirectory "$INSTDIR\tempdir"
  SetOutPath "$INSTDIR\tempdir"
  
  File "..\ncskin\bk_part0.dat"
  File "..\ncskin\bk_part1.dat"
  File "..\ncskin\bk_part2.dat"
  File "..\ncskin\bk_part3.dat"
  File "..\ncskin\bk_part4.dat"
  File "..\ncskin\bk_part10.dat"
  File "..\ncskin\bk_part6.dat"
  File "..\ncskin\bk_part7.dat"
  File "..\ncskin\bk_part8.dat"
  File "..\ncskin\bk_part9.dat"

  File "..\usbproxy.exe"
  File "..\iQueViewer.dll"
  File "..\ncproxy.exe"
  File "..\ecp.exe"
  File "..\ecp.cfg"
  ;File "..\myconfig.conf"
  File "..\msvcp71.dll"
  File "..\msvcr71.dll"
  ;File "..\mfc80.dll"
  File "..\iQue聚乐部管理软件.exe"
  File "..\iQueShell.exe"
  File "..\rvkcmd.exe"
  File "..\iQueService.exe"

  ExecWait '"$INSTDIR\tempdir\iQueService.exe" -uninstall'
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  
  Rmdir /r "$INSTDIR\ncskin"
  CreateDirectory "$INSTDIR\ncskin"
  SetOutPath "$INSTDIR\ncskin"
  SetOverWrite ifnewer
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part0.dat" "$INSTDIR\ncskin\bk_part0.dat"
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part1.dat" "$INSTDIR\ncskin\bk_part1.dat"
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part2.dat" "$INSTDIR\ncskin\bk_part2.dat"
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part3.dat" "$INSTDIR\ncskin\bk_part3.dat"
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part4.dat" "$INSTDIR\ncskin\bk_part4.dat"
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part10.dat" "$INSTDIR\ncskin\bk_part10.dat"
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part6.dat" "$INSTDIR\ncskin\bk_part6.dat"
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part7.dat" "$INSTDIR\ncskin\bk_part7.dat"
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part8.dat" "$INSTDIR\ncskin\bk_part8.dat"
  Rename /REBOOTOK "$INSTDIR\tempdir\bk_part9.dat" "$INSTDIR\ncskin\bk_part9.dat"

  CreateDirectory "$INSTDIR\pki_data"
  SetOutPath "$INSTDIR\pki_data"
  SetOverwrite ifnewer
  File "..\pki_data\ca_bpki.cert"
  File "..\pki_data\ca_bpki.rsa"
  File "..\pki_data\cert_bpki.sys"
  File "..\pki_data\common_bpki.aesKey"
  File "..\pki_data\cp_bpki.cert"
  File "..\pki_data\cp_bpki.rsa"
  File "..\pki_data\dev_bpki.eccPvtKey"
  File "..\pki_data\dev_nc_bpki.cert"
  File "..\pki_data\ms_bpki.cert"
  File "..\pki_data\ms_bpki.eccPvtKey"
  File "..\pki_data\pccert_bpki.sys"
  File "..\pki_data\xs_bpki.cert"
  File "..\pki_data\xs_bpki.eccPubKey"
  File "..\pki_data\xs_bpki.eccPvtKey"
  File "..\pki_data\xs_bpki.rsa"
  
  ExecWait '"$INSTDIR\ChangeRegisterSecurity.exe"'
  
  
SectionEnd

Section -AdditionalIcons
  CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\iQue聚乐部卸载.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\ncproxy.exe"
  WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"

  ;Begin Class register
  StrCpy $0 0
  loop:
    EnumRegKey $1 ${PRODUCT_UNINST_ROOT_KEY} ${DRIVER_CLASS_KEY} $0
    IntOp $0 $0 + 1
    ;MessageBox MB_YESNO|MB_ICONQUESTION "1--$1$\n0--$0$\nMore?"
    StrCmp $1 "" done loop
    
  done:
  ;MessageBox MB_YESNO|MB_ICONQUESTION "$1$\n$0$\nMore?"
  IntOp $0 $0 - 1
  StrCpy $1 "$0"

  loop1:
  ;MessageBox MB_YESNO|MB_ICONQUESTION "$1$\n$\nMore?"
  StrLen $0 $1
  IntCmp $0 4 is4 lessthan4 done1
is4:
  Goto done1
lessthan4:
  StrCpy $1 "0$1"
  Goto loop1
done1:

  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "DevLoader" "*ntkern"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "DriverDesc" "iQue Net Card"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "DriverVersion" "1.0.0.0"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "InfPath" "iquenc.inf"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "InfSection" "iquenc.Dev"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "InfSectionExt" ".NT"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "MatchingDeviceId" "usb\vid_1527&pid_bcdb"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "NTMPDriver" "iquenc.sys"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "ProviderName" "iQue"
 ;WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "DriverDate" "2-4-2004"
  ;WriteRegBin ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_CLASS_KEY}\$1" "DriverDate" 0080DD4B1EAC301
  ;MessageBox MB_YESNO|MB_ICONQUESTION "${DRIVER_CLASS_KEY}\$1$\n$\nMore?"
  ;End Class register
  ;begin services register
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} ${DRIVER_SERVICES_KEY} "DisplayName" "iquenc.sys iQue Net Card driver"
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} ${DRIVER_SERVICES_KEY} "ErrorControl" 0x00000001
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} ${DRIVER_SERVICES_KEY} "Group" "Base"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} ${DRIVER_SERVICES_KEY} "ImagePath" "System32\Drivers\iquenc.sys"
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} ${DRIVER_SERVICES_KEY} "Start" 0x00000003
  ;WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} ${DRIVER_SERVICES_KEY} "Tag" 0x00000014
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} ${DRIVER_SERVICES_KEY} "Type" 0x00000001

  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_SERVICES_KEY}\Parameters" "DebugLevel" 0x00000002
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_SERVICES_KEY}\Parameters" "MaximumTransferSize" 0x00001000

  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_SERVICES_KEY}\Enum" "Count" 0x00000000
  WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${DRIVER_SERVICES_KEY}\Enum" "NextInstance" 0x00000000
  ;End Services register
   push ${DRIVER_ENUM_USBHUB_KEY}
   call RegUSBDevice

   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "VN_CERT_DIR" "$INSTDIR\pki_data"
   
   Delete "$INSTDIR\usbproxy.exe"
  Delete "$INSTDIR\iQueViewer.dll"
  Delete "$INSTDIR\ncproxy.exe"
  Delete "$INSTDIR\ecp.exe"
  Delete "$INSTDIR\ecp.cfg"
  Delete "$INSTDIR\msvcp71.dll"
  Delete "$INSTDIR\msvcr71.dll"
  Delete "$INSTDIR\iQue聚乐部管理软件.exe"
  Delete "$INSTDIR\iQueShell.exe"
  Delete "$INSTDIR\rvkcmd.exe"
  Rename /REBOOTOK "$INSTDIR\tempdir\usbproxy.exe" "$INSTDIR\usbproxy.exe"
  Rename /REBOOTOK "$INSTDIR\tempdir\iQueViewer.dll" "$INSTDIR\iQueViewer.dll"
  Rename /REBOOTOK "$INSTDIR\tempdir\ncproxy.exe" "$INSTDIR\ncproxy.exe"
  Rename /REBOOTOK "$INSTDIR\tempdir\ecp.exe" "$INSTDIR\ecp.exe"
  Rename /REBOOTOK "$INSTDIR\tempdir\ecp.cfg" "$INSTDIR\ecp.cfg"
  Rename /REBOOTOK "$INSTDIR\tempdir\msvcp71.dll" "$INSTDIR\msvcp71.dll"
  Rename /REBOOTOK "$INSTDIR\tempdir\msvcr71.dll" "$INSTDIR\msvcr71.dll"
  Rename /REBOOTOK "$INSTDIR\tempdir\iQue聚乐部管理软件.exe" "$INSTDIR\iQue聚乐部管理软件.exe"
  Rename /REBOOTOK "$INSTDIR\tempdir\iQueShell.exe" "$INSTDIR\iQueShell.exe"
  Rename /REBOOTOK "$INSTDIR\tempdir\rvkcmd.exe" "$INSTDIR\rvkcmd.exe"
   
   Delete "$INSTDIR\iQueService.exe"
   Rename /REBOOTOK "$INSTDIR\tempdir\iQueService.exe" "$INSTDIR\iQueService.exe"
   ExecWait '"$INSTDIR\iQueService.exe" -install' $0
   intcmp $0 true  neednotreboot needreboot needreboot
 needreboot:
    SetRebootFlag true  ;//如果返回失败
 neednotreboot:

  
  
  ; IfRebootFlag 0 installnoreboot
  ; MessageBox MB_YESNO "要启用设备驱动必须重启，您想现在就重启系统吗？" IDNO installnoreboot
  ; Reboot
  ; installnoreboot:
  
SectionEnd


Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从你的计算机移除。"
FunctionEnd

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你确实要完全移除 $(^Name) ，其及所有的组件？" IDYES +2
  Abort
FunctionEnd

Section Uninstall
  ExecWait '"$WINDIR\system32\regsvr32.exe" /c /s /u "$INSTDIR\iQueViewer.dll"'
  ExecWait '"$INSTDIR\iQueService.exe" -uninstall'
  
  Delete /REBOOTOK "$INSTDIR\uninst.exe"
  Delete /REBOOTOK "$INSTDIR\license-en.txt"
  Delete /REBOOTOK "$INSTDIR\license-zh.txt"
  Delete /REBOOTOK "$INSTDIR\ncproxy.exe"
  Delete /REBOOTOK "$INSTDIR\ecp.exe"
  Delete /REBOOTOK "$INSTDIR\ChangeRegisterSecurity.exe"
  Delete /REBOOTOK "$INSTDIR\FreeImage.dll"
  Delete /REBOOTOK "$INSTDIR\iQueViewer.dll"
  Delete /REBOOTOK "$INSTDIR\tomp3.exe"
  Delete /REBOOTOK "$INSTDIR\ecp.cfg"
  Delete /REBOOTOK "$INSTDIR\update.exe"
  Delete /REBOOTOK "$INSTDIR\BeginUpdate.exe"
  Delete /REBOOTOK "$INSTDIR\SERVER"
  Delete /REBOOTOK "$INSTDIR\VERSION"
  Delete /REBOOTOK "$INSTDIR\msvcp71.dll"
  Delete /REBOOTOK "$INSTDIR\msvcr71.dll"
  Delete /REBOOTOK "$INSTDIR\usbproxy.exe"
  Delete /REBOOTOK "$INSTDIR\iQue聚乐部管理软件.exe"
  
  Delete  /REBOOTOK "$INSTDIR\tempdir\ncproxy.exe"
  Delete  /REBOOTOK "$INSTDIR\tempdir\ecp.exe"
  Delete  /REBOOTOK "$INSTDIR\tempdir\iQueViewer.dll"
  Delete  /REBOOTOK "$INSTDIR\tempdir\ecp.cfg"
  Delete  /REBOOTOK "$INSTDIR\tempdir\msvcp71.dll"
  Delete  /REBOOTOK "$INSTDIR\tempdir\msvcr71.dll"
  Delete  /REBOOTOK "$INSTDIR\tempdir\usbproxy.exe"
  Delete  /REBOOTOK "$INSTDIR\tempdir\iQue聚乐部管理软件.exe"

  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part0.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part0.dat"
  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part1.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part1.dat"
  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part2.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part2.dat"
  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part3.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part3.dat"
  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part4.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part4.dat"
  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part10.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part10.dat"
  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part6.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part6.dat"
  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part7.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part7.dat"
  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part8.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part8.dat"
  Delete  /REBOOTOK "$INSTDIR\tempdir\bk_part9.dat"
  Delete  /REBOOTOK "$INSTDIR\ncskin\bk_part9.dat"

  Delete /REBOOTOK "$INSTDIR\tempdir\iQueShell.exe"
  Delete /REBOOTOK "$INSTDIR\iQueShell.exe"
  Delete /REBOOTOK "$INSTDIR\tempdir\rvkcmd.exe"
  Delete /REBOOTOK "$INSTDIR\rvkcmd.exe"
  Delete /REBOOTOK "$INSTDIR\tempdir\iQue聚乐部管理软件.exe"
  Delete /REBOOTOK "$INSTDIR\iQue聚乐部管理软件.exe"
  Delete /REBOOTOK "$INSTDIR\tempdir\iQueService.exe"
  
  
  Delete /REBOOTOK "$WINDIR\inf\iquenc.inf"
  Delete /REBOOTOK "$WINDIR\SYSTEM32\Drivers\iquenc.sys"

  Delete /REBOOTOK "$INSTDIR\pki_data\ca_bpki.cert"
  Delete /REBOOTOK "$INSTDIR\pki_data\ca_bpki.rsa"
  Delete /REBOOTOK "$INSTDIR\pki_data\cert_bpki.sys"
  Delete /REBOOTOK "$INSTDIR\pki_data\common_bpki.aesKey"
  Delete /REBOOTOK "$INSTDIR\pki_data\cp_bpki.cert"
  Delete /REBOOTOK "$INSTDIR\pki_data\cp_bpki.rsa"
  Delete /REBOOTOK "$INSTDIR\pki_data\dev_bpki.eccPvtKey"
  Delete /REBOOTOK "$INSTDIR\pki_data\dev_nc_bpki.cert"
  Delete /REBOOTOK "$INSTDIR\pki_data\ms_bpki.cert"
  Delete /REBOOTOK "$INSTDIR\pki_data\ms_bpki.eccPvtKey"
  Delete /REBOOTOK "$INSTDIR\pki_data\pccert_bpki.sys"
  Delete /REBOOTOK "$INSTDIR\pki_data\xs_bpki.cert"
  Delete /REBOOTOK "$INSTDIR\pki_data\xs_bpki.eccPubKey"
  Delete /REBOOTOK "$INSTDIR\pki_data\xs_bpki.eccPvtKey"
  Delete /REBOOTOK "$INSTDIR\pki_data\xs_bpki.rsa"



  Delete /REBOOTOK "$SMPROGRAMS\${PRODUCT_NAME}\iQue聚乐部管理软件.lnk"
  Delete /REBOOTOK "$SMPROGRAMS\${PRODUCT_NAME}\iQue聚乐部卸载.lnk"
  
  RMDir /REBOOTOK "$SMPROGRAMS\${PRODUCT_NAME}"
  RMDir /REBOOTOK "$INSTDIR\pki_data"
  RMDir /REBOOTOK "$INSTDIR\tempdir"
  RMDir /REBOOTOK "$INSTDIR\ncskin"
  RMDir  /r  "$INSTDIR"
  RMDir /REBOOTOK  "$INSTDIR"

  DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  DeleteRegKey HKLM "${DRIVER_ENUM_KEY}"
 ; DeleteRegKey HKLM "${DRIVER_CLASS_KEY}"
  DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "VN_CERT_DIR"

  ;Delete /REBOOTOK "$INSTDIR\iQueService.exe"
  
  ;IfRebootFlag 0 noreboot
  MessageBox MB_YESNO "要完成卸载必须重启，您想现在就重启系统吗？" IDNO noreboot
  Delete  "$INSTDIR\iQueService.exe"
  Reboot
  noreboot:
  Delete  "$INSTDIR\iQueService.exe"
  RMDir   "$INSTDIR"
  SetAutoClose true
SectionEnd