DXGL r11 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r10‎ | r11 | r12 >
Date:22:19, 23 November 2011
Author:admin
Status:new
Tags:
Comment:
Create routine in installer for enumerating application install directories.
Modified paths:
  • /Installer/dxgl.nsi (modified) (history)
  • /Installer/version.nsh (added) (history)

Diff [purge]

Index: Installer/dxgl.nsi
@@ -2,14 +2,17 @@
33
44 SetCompressor /SOLID lzma
55
 6+!include 'LogicLib.nsh'
 7+
 8+
69 ; HM NIS Edit Wizard helper defines
710 !define PRODUCT_NAME "DXGL"
8 -!define PRODUCT_VERSION "0.0.6"
911 !define PRODUCT_PUBLISHER "William Feely"
1012 !define PRODUCT_WEB_SITE "https://www.williamfeely.info/wiki/DXGL"
1113 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\dxglcfg.exe"
1214 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
1315 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
 16+!include "version.nsh"
1417
1518 ; MUI2
1619 !include "MUI2.nsh"
@@ -41,8 +44,20 @@
4245
4346 ; MUI end ------
4447
 48+
 49+!define HKEY_CURRENT_USER 0x80000001
 50+!define RegOpenKeyEx "Advapi32::RegOpenKeyEx(i, t, i, i, *i) i"
 51+!define RegQueryValueEx "Advapi32::RegQueryValueEx(i, t, i, *i, i, *i) i"
 52+!define RegCloseKey "Advapi32::RegCloseKey(i) i"
 53+!define REG_MULTI_SZ 7
 54+!define INSTPATH "InstallPaths"
 55+!define KEY_QUERY_VALUE 0x0001
 56+!define KEY_ENUMERATE_SUB_KEYS 0x0008
 57+!define ROOT_KEY ${HKEY_CURRENT_USER}
 58+Var SUBKEY
 59+
4560 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
46 -OutFile "DXGL-0.0.6-win32.exe"
 61+OutFile "DXGL-${PRODUCT_VERSION}-win32.exe"
4762 InstallDir "$PROGRAMFILES\DXGL"
4863 InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
4964 ShowInstDetails show
@@ -59,6 +74,74 @@
6075 File "..\Release\ddraw.dll"
6176 File "..\ReadMe.txt"
6277 File "..\COPYING.txt"
 78+
 79+ StrCpy $8 0
 80+ SetPluginUnload alwaysoff
 81+ regloop:
 82+ EnumRegKey $SUBKEY HKCU "Software\DXGL" $8
 83+ StrCmp $SUBKEY "" regdone
 84+ StrCpy $SUBKEY "Software\DXGL\$SUBKEY"
 85+ MessageBox MB_OK "$SUBKEY"
 86+ IntOp $8 $8 + 1
 87+ ;REG_MULTI_SZ reader based on code at http://nsis.sourceforge.net/REG_MULTI_SZ_Reader
 88+ StrCpy $0 ""
 89+ StrCpy $1 ""
 90+ StrCpy $2 ""
 91+ StrCpy $3 ""
 92+ System::Call "${RegOpenKeyEx}(${ROOT_KEY},'$SUBKEY',0, \
 93+ ${KEY_QUERY_VALUE}|${KEY_ENUMERATE_SUB_KEYS},.r0) .r3"
 94+ StrCmp $3 0 readvalue
 95+ Goto regloop
 96+ readvalue:
 97+ System::Call "${RegQueryValueEx}(r0,'${INSTPATH}',0,.r1,0,.r2) .r3"
 98+ StrCmp $3 0 checksz
 99+ goto readdone
 100+ checksz:
 101+ StrCmp $1 ${REG_MULTI_SZ} checkempty
 102+ MessageBox MB_OK|MB_ICONSTOP "Registry value no REG_MULTI_SZ! ($3)"
 103+ Goto readdone
 104+ checkempty:
 105+ StrCmp $2 0 0 multiszalloc
 106+ MessageBox MB_OK|MB_ICONSTOP "Registry value empty! ($3)"
 107+ Goto readdone
 108+ multiszalloc:
 109+ System::Alloc $2
 110+ Pop $1
 111+ StrCmp $1 0 0 multiszget
 112+ MessageBox MB_OK|MB_ICONSTOP "Can't allocate enough memory! ($3)"
 113+ Goto readdone
 114+ multiszget:
 115+ System::Call "${RegQueryValueEx}(r0, '${INSTPATH}', 0, n, r1, r2) .r3"
 116+ StrCmp $3 0 multiszprocess
 117+ MessageBox MB_OK|MB_ICONSTOP "Can't query registry value data! ($3)"
 118+ System::Free $1
 119+ Goto readdone
 120+ multiszprocess:
 121+ StrCpy $4 $1
 122+ IntOp $6 $4 + $2
 123+ !ifdef NSIS_UNICODE
 124+ IntOp $6 $6 - 2
 125+ !else
 126+ IntOp $6 $6 - 1
 127+ !endif
 128+ szloop:
 129+ System::Call "*$4(&t${NSIS_MAX_STRLEN} .r3)"
 130+ StrLen $5 $3
 131+ IntOp $5 $5 + 1
 132+ !ifdef NSIS_UNICODE
 133+ IntOp $5 $5 * 2
 134+ !endif
 135+ IntOp $4 $4 + $5
 136+ MessageBox MB_OK "$3"
 137+ IntCmp IntCmp $4 $6 0 szloop
 138+ System::Free $1
 139+
 140+ readdone:
 141+ StrCmp $0 0 regloop
 142+ System::Call "${RegCloseKey}(r0)"
 143+ goto regloop
 144+ regdone:
 145+ SetPluginUnload manual
63146 SectionEnd
64147
65148 Section -AdditionalIcons
Index: Installer/version.nsh
@@ -0,0 +1 @@
 2+!define PRODUCT_VERSION "0.1.0"
\ No newline at end of file