summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2015-02-03 10:40:25 -0800
committerMichael Vrhel <michael.vrhel@artifex.com>2015-02-03 14:18:50 -0800
commitaba57a20134e06fe8c81836ccdf9b94ad1ce2d71 (patch)
treeb182abedef411752b65805f22ea4c64d249bfe1e
parentff89d591b7ed859534bfdf31c6a48913ab22ab5b (diff)
downloadmupdf-aba57a20134e06fe8c81836ccdf9b94ad1ce2d71.tar.xz
Installer changes for gsview.nsi
Addition of license information. Also changes to ensure registry keys used by application are removed during the uninstall. Many changes in the installer code to ensure that the file type associations are made and the proper icons are displayed for each file type.
-rw-r--r--platform/windows/gsview/LICENSE66
-rw-r--r--platform/windows/gsview/MainWindow.xaml.cs19
-rw-r--r--platform/windows/gsview/nsis/gsview.nsi466
3 files changed, 440 insertions, 111 deletions
diff --git a/platform/windows/gsview/LICENSE b/platform/windows/gsview/LICENSE
new file mode 100644
index 00000000..4fd64b19
--- /dev/null
+++ b/platform/windows/gsview/LICENSE
@@ -0,0 +1,66 @@
+This End User License Agreement (“Agreement”) is a legal agreement between ARTIFEX SOFTWARE INC., a California corporation with its principal place of business as 7 Mt. Lassen Drive, A-134, San Rafael, California 94903 (“Artifex”) and you (either an individual or an entity, as identified in your invoice regarding the use of Artifex's software for which you have purchased a license, including any documentation that may be included in the software (together, the “Software”).
+
+
+Grant of License.
+
+Subject to the restrictions herein, and payment of the applicable license fees, Artifex hereby grants to you the personal, nontransferable, non-exclusive right to use the Software, for internal purposes only. You may use the Software as follows, depending on the licenses you have ordered as reflected in your invoice:
+
+• Individual License. You may use the Software, on only one computer, and only by one user, at a time. You may not store the Software on a server that enables access via multiple computers.
+
+• Multiple Licenses. One user may use one copy of the Software for each license you have purchased. You may make a reasonable number of copies to support such use.
+
+• Site License. All of your employees located at a particular site, as indicated in your invoice, may use the Software via computers located at that site, provided the employee’s primary office is at that site. For clarity, a computer will be considered on-site when a user accesses the Software via that computer, even if the Software is being served from offsite servers, and even if the users access their primary computers via virtualization or remote access.
+
+• Enterprise License. All your employees may use the Software regardless of the number of copies or locations.
+
+
+Copyright.
+
+The Software is licensed to you, not sold. All copies of the Software are the property of Artifex. Artifex reserves all intellectual property rights in the Software. The Software is protected by United States copyright and other intellectual property laws and international treaty provisions. Therefore, you may not use, copy, modify or distribute the Software without authorization. You may make a reasonable number of copies of the Software solely for backup or archival purposes.
+
+
+Restrictions.
+
+You may not rent, lease, or loan the Software. You may not reverse engineer, decompile, or disassemble the Software, except to the extent the foregoing restriction is prohibited by applicable law. You may not modify, or create derivative works based upon the Software. You many not use the Software to make its functionality available to others, such as via software-as-a-service offerings. If you make any copy of the Software, you must retain all copyright and other intellectual property notices.
+
+
+Open Source Licensing.
+
+Artifex may offer versions of the Software under open source licenses such as the Affero General Public License 3.0. This Agreement will not vitiate any rights you may have separately under such open source licenses.
+
+Termination.
+
+You may terminate the license granted in this Agreement by so advising Artifex in writing. The license granted in this Agreement will terminate automatically upon any violation by you of its terms or conditions. Upon termination of the license, you must destroy all your copies of the Software.
+
+
+Updates.
+
+The right to receive support or updates to the Software may be subject to additional terms, conditions or charges. Please contact Artifex for additional information about maintenance and support programs. To the extent you are provided updates, revisions, or new versions of the Software, this Agreement will govern them and they will be considered part of the Software hereunder, unless you and Artifex agree to a new license agreement covering them.
+
+
+NO WARRANTIES.
+
+YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO MEET YOUR NEEDS. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, ARTIFEX DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. SOME STATES DO NOT ALLOW LIMITATIONS ON IMPLIED WARRANTIES, SO THE ABOVE LIMITATION MAY NOT APPLY TO YOU.
+
+
+NO LIABILITY FOR CONSEQUENTIAL DAMAGES.
+
+IN NO EVENT WILL ARTIFEX OR ITS SUPPLIERS OR LICENSORS BE LIABLE FOR ANY CONSEQUENTIAL, INCIDENTAL, OR INDIRECT DAMAGES (INCLUDING WITHOUT LIMITATION DAMAGES FOR LOSS OF BUSINESS PROFITS OR BUSINESS INTERRUPTION) ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO EVENT WILL ARTIFEX OR ITS SUPPLIERS OR LICENSORS BE LIABLE FOR MORE THAN THE AMOUNT ACTUALLY PAID BY YOU TO ARTIFEX FOR THE SOFTWARE. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.
+
+
+U.S. Government-Restricted Rights.
+
+The Software and accompanying documentation are deemed to be "commercial computer Software" and "commercial computer Software documentation," respectively, pursuant to DFAR Section 227.7202 and FAR Section 12.212(b), as applicable. Any use, modification, reproduction release, performance, display or disclosure of the Software and accompanying documentation, and any derivative works thereof, by the U.S. Government will be governed solely by the terms of this Agreement.
+
+
+Export Restrictions.
+
+You may not download, export, or re-export the Software (a) into, or to a national or resident of, any country to which the United States has embargoed goods, or (b) to anyone on the United States Treasury Department's list of Specially Designated Nationals or the U.S. Commerce Department's Table of Deny Orders. By downloading or using the Software, you are representing and warranting that you are not located in, under the control of, or a national or resident of any such country or on any such list.
+
+
+General.
+
+This Agreement is governed by the laws of the United States and the State of California, without reference to conflict of laws principles. Any dispute between you and Artifex arising out of or relating to this Agreement will be subject to the exclusive venue and jurisdiction of the state and federal courts located in Marin County, California. This Agreement is the entire agreement between you and Artifex and supersedes any prior agreements relating thereto. If any provision of this Agreement is held invalid, the remainder of this Agreement will continue in full force and effect and the invalid provision will be reformed and enforced to reflect the original intent of the parties.
+
+
+Should you have any questions concerning this Agreement, or if you desire to contact Artifex for any reason, please contact: miles.jones@artifex.com
diff --git a/platform/windows/gsview/MainWindow.xaml.cs b/platform/windows/gsview/MainWindow.xaml.cs
index fd26a50b..c6979231 100644
--- a/platform/windows/gsview/MainWindow.xaml.cs
+++ b/platform/windows/gsview/MainWindow.xaml.cs
@@ -21,6 +21,9 @@ using System.Printing;
using System.Windows.Markup;
using System.Runtime.InteropServices;
using Microsoft.Win32; /* For registry */
+using System.Reflection;
+using System.Diagnostics;
+
public enum AA_t
{
@@ -597,12 +600,23 @@ namespace gsview
return result;
}
+ private String GetVersion()
+ {
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
+ String vers = fileVersionInfo.ProductVersion;
+ String[] parts = vers.Split('.');
+ String simple_vers = parts[0] + '.' + parts[1];
+ return simple_vers;
+ }
+
/* Initialize from registry */
private void InitFromRegistry()
{
RegistryKey key = Registry.CurrentUser.CreateSubKey("Software");
RegistryKey keyA = key.CreateSubKey("Artifex Software");
- RegistryKey keygs = keyA.CreateSubKey("GSview 6.0");
+ String vers = GetVersion();
+ RegistryKey keygs = keyA.CreateSubKey("gsview " + vers);
String filepath = null;
Int32 page;
AA_t aa = AA_t.HIGH;
@@ -640,7 +654,8 @@ namespace gsview
RegistryKey key = Registry.CurrentUser.CreateSubKey("Software");
RegistryKey keyA = key.CreateSubKey("Artifex Software");
- RegistryKey keygs = keyA.CreateSubKey("GSview 6.0");
+ String vers = GetVersion();
+ RegistryKey keygs = keyA.CreateSubKey("gsview " + vers);
if (m_origfile != null && (m_document_type == DocumentTypes.PS ||
m_document_type == DocumentTypes.EPS))
diff --git a/platform/windows/gsview/nsis/gsview.nsi b/platform/windows/gsview/nsis/gsview.nsi
index 78ebe272..f2bba6e9 100644
--- a/platform/windows/gsview/nsis/gsview.nsi
+++ b/platform/windows/gsview/nsis/gsview.nsi
@@ -13,15 +13,15 @@
; CA 94903, U.S.A., +1(415)492-9861, for further information.
;
-; This script should be compiled with e.g.:
+; This script should be compiled with :
; makensis -NOCD nsis/gsview.nsi
!ifndef TARGET
-!define TARGET gsview
+!define TARGET gsview_setup
!endif
!ifndef VERSION
-!define VERSION 6.00
+!define VERSION 6.0
!endif
!ifndef PRODUCT_NAME
@@ -32,22 +32,87 @@ SetCompressor /SOLID /FINAL lzma
XPStyle on
CRCCheck on
+!include "nsDialogs.nsh"
+; modern user interface
!include "MUI2.nsh"
; for logic marcos that occur at run time. Not compile time
!include "LogicLib.nsh"
; for detecting if running on x64 machine.
!include "x64.nsh"
-; for file association. from source forge http://nsis.sourceforge.net/FileAssoc
-; place this in the header location of your nsis install
-!include "fileassoc.nsh"
-!define MUI_FINISHPAGE_RUN
+; Macros for file association.
+; to make sure that we update the proper locations (user vs root for example
+; as well as changes needed for Windows 8.x)
+!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND TOAST SETDEFAULT
+ ; Backup the previously associated file class
+
+ ${If} ${SETDEFAULT} == "1"
+ ;DetailPrint "ReadRegStr HKCU Software\Classes\ $R0"
+ ReadRegStr $R0 HKCU "Software\Classes\.${EXT}" ""
+
+ ;DetailPrint "WriteRegStr of backup in HKCU"
+ WriteRegStr HKCU "Software\Classes\.${EXT}" "${FILECLASS}_backup" "$R0"
+
+ ;DetailPrint "WriteRegStr of fileclass in HKCU"
+ WriteRegStr HKCU "Software\Classes\.${EXT}" "" "${FILECLASS}"
+
+ ; If this key is present (as it in windows 8) then we need to do this to get the
+ ; proper file type icon rather than just the application icon for the file type.
+ ${If} ${TOAST} == '1'
+ WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts\" "${FILECLASS}_" 0
+ ${EndIf}
+ ${EndIf}
+
+ ; The icon mapping should not go in HKCR but in HKLM per MS best practices
+ WriteRegStr HKLM "Software\Classes\${FILECLASS}" "" `${DESCRIPTION}`
+ WriteRegStr HKLM "Software\Classes\${FILECLASS}\DefaultIcon" "" `${ICON}`
+ WriteRegStr HKLM "Software\Classes\${FILECLASS}\shell" "" "open"
+ WriteRegStr HKLM "Software\Classes\${FILECLASS}\shell\open" "" `${COMMANDTEXT}`
+ WriteRegStr HKLM "Software\Classes\${FILECLASS}\shell\open\command" "" `${COMMAND}`
+!macroend
+
+!macro APP_UNASSOCIATE EXT FILECLASS TOAST
+ ; Get the previously associated file class
+ ReadRegStr $R0 HKCU "Software\Classes\.${EXT}" `${FILECLASS}_backup`
+ WriteRegStr HKCU "Software\Classes\.${EXT}" "" "$R0"
+
+ ; Delete backup value
+ DeleteRegValue HKCU "Software\Classes\.${EXT}" "${FILECLASS}_backup"
+
+ ; If this key is present (as it in windows 8) then attempt to clean up. System
+ ; seems to add in other entries here that I did not do depending upon what the
+ ; type of associations the user has done.
+ ${If} ${TOAST} == '1'
+ DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts\" "${FILECLASS}_"
+ ${EndIf}
+
+ ; Remove icon mapping
+ DeleteRegKey HKLM `Software\Classes\${FILECLASS}`
+!macroend
+
+; defines for use with SHChangeNotify
+!ifdef SHCNE_ASSOCCHANGED
+!undef SHCNE_ASSOCCHANGED
+!endif
+!define SHCNE_ASSOCCHANGED 0x08000000
+!ifdef SHCNF_FLUSH
+!undef SHCNF_FLUSH
+!endif
+!define SHCNF_FLUSH 0x1000
+
+!macro UPDATEFILEASSOC
+ System::Call "shell32::SHChangeNotify(i,i,i,i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_FLUSH}, 0, 0)"
+!macroend
+
+!define MUI_FINISHPAGE_RUN "$INSTDIR\bin\gsview.exe"
!define MUI_FINISHPAGE_LINK "Visit the Ghostscript web site"
!define MUI_FINISHPAGE_LINK_LOCATION http://www.ghostscript.com/
+; Order of page appearance
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
+Page custom fnc_association_Show fnc_association_Done
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
@@ -57,10 +122,14 @@ CRCCheck on
!echo "Building ${WINTYPE}-bit installer"
Name "gsview"
-OutFile "${TARGET}.exe"
+OutFile "${TARGET}_${VERSION}.exe"
Icon Resources\gsview_app.ico
UninstallIcon Resources\gsview_app.ico
+; We need to have then run this as an adminstrator. Otherwise there are
+; issues with the icons for the various file types and getting the "Open With.."
+; items populated
+
RequestExecutionLevel admin
; Some default compiler settings (uncomment and change at will):
@@ -81,61 +150,220 @@ InstallDir "$PROGRAMFILES64\Artifex Software\gsview${VERSION}"
DirText "Select the directory to install gsview in:"
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+; Association dialog: Partially created with CoolSoft NSIS Dialog Designer.
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+Var hCtl_association
+Var hCtl_association_jpg
+Var hCtl_association_png
+Var hCtl_association_xps
+Var hCtl_association_oxps
+Var hCtl_association_eps
+Var hCtl_association_ps
+Var hCtl_association_cbz
+Var hCtl_association_pdf
+Var jpg
+Var png
+Var xps
+Var oxps
+Var eps
+Var ps
+Var cbz
+Var pdf
+
+; dialog create function
+Function fnc_association_Create
+
+ ; === association (type: Dialog) ===
+ nsDialogs::Create 1018
+ Pop $hCtl_association
+ ${If} $hCtl_association == error
+ Abort
+ ${EndIf}
+ !insertmacro MUI_HEADER_TEXT "File Type Associations" "Select.."
+
+ ; === jpg (type: Checkbox) ===
+ ${NSD_CreateCheckbox} 192.2u 57.85u 78.99u 23.38u "jpg"
+ Pop $hCtl_association_jpg
+ ${NSD_Check} $hCtl_association_jpg
+
+ ; === png (type: Checkbox) ===
+ ${NSD_CreateCheckbox} 192.2u 43.69u 68.46u 14.77u "png"
+ Pop $hCtl_association_png
+ ${NSD_Check} $hCtl_association_png
+
+ ; === xps (type: Checkbox) ===
+ ${NSD_CreateCheckbox} 123.09u 45.54u 70.43u 11.69u "xps"
+ Pop $hCtl_association_xps
+ ${NSD_Check} $hCtl_association_xps
+
+ ; === oxps (type: Checkbox) ===
+ ${NSD_CreateCheckbox} 123.09u 57.85u 73.06u 23.38u "oxps"
+ Pop $hCtl_association_oxps
+ ${NSD_Check} $hCtl_association_oxps
+
+ ; === eps (type: Checkbox) ===
+ ${NSD_CreateCheckbox} 50.68u 80.62u 68.46u 14.77u "eps"
+ Pop $hCtl_association_eps
+ ${NSD_Check} $hCtl_association_eps
+
+ ; === ps (type: Checkbox) ===
+ ${NSD_CreateCheckbox} 50.68u 62.15u 62.53u 14.77u "ps"
+ Pop $hCtl_association_ps
+ ${NSD_Check} $hCtl_association_ps
+
+ ; === cbz (type: Checkbox) ===
+ ${NSD_CreateCheckbox} 192.2u 80.62u 68.46u 14.77u "cbz"
+ Pop $hCtl_association_cbz
+ ${NSD_Check} $hCtl_association_cbz
+
+ ; === pdf (type: Checkbox) ===
+ ${NSD_CreateCheckbox} 50.68u 43.69u 68.46u 14.77u "pdf"
+ Pop $hCtl_association_pdf
+ ${NSD_Check} $hCtl_association_pdf
+
+FunctionEnd
+
+; Association dialog show function
+Function fnc_association_Show
+ Call fnc_association_Create
+ nsDialogs::Show $hCtl_association
+FunctionEnd
+
+; Association dialog done function
+Function fnc_association_Done
+ ${NSD_GetState} $hCtl_association_jpg $0
+ ${If} $0 <> 0
+ StrCpy $jpg "1"
+ ${Else}
+ StrCpy $jpg "0"
+ ${EndIf}
+
+ ${NSD_GetState} $hCtl_association_xps $0
+ ${If} $0 <> 0
+ StrCpy $xps "1"
+ ${Else}
+ StrCpy $xps "0"
+ ${EndIf}
+
+ ${NSD_GetState} $hCtl_association_oxps $0
+ ${If} $0 <> 0
+ StrCpy $oxps "1"
+ ${Else}
+ StrCpy $oxps "0"
+ ${EndIf}
+
+ ${NSD_GetState} $hCtl_association_png $0
+ ${If} $0 <> 0
+ StrCpy $png "1"
+ ${Else}
+ StrCpy $png "0"
+ ${EndIf}
+
+ ${NSD_GetState} $hCtl_association_eps $0
+ ${If} $0 <> 0
+ StrCpy $eps "1"
+ ${Else}
+ StrCpy $eps "0"
+ ${EndIf}
+
+ ${NSD_GetState} $hCtl_association_ps $0
+ ${If} $0 <> 0
+ StrCpy $ps "1"
+ ${Else}
+ StrCpy $ps "0"
+ ${EndIf}
+
+ ${NSD_GetState} $hCtl_association_cbz $0
+ ${If} $0 <> 0
+ StrCpy $cbz "1"
+ ${Else}
+ StrCpy $cbz "0"
+ ${EndIf}
+
+ ${NSD_GetState} $hCtl_association_pdf $0
+ ${If} $0 <> 0
+ StrCpy $pdf "1"
+ ${Else}
+ StrCpy $pdf "0"
+ ${EndIf}
+
+FunctionEnd
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+; Main Install Section
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Section "" ; (default section)
-; First check if we have the proper .net installed
-Call CheckAndDownloadDotNet45
-
-SetOutPath "$INSTDIR"
-CreateDirectory "$INSTDIR\bin"
-CreateDirectory "$INSTDIR\resources"
-; add files / whatever that need to be installed here.
-${If} ${RunningX64}
- File /oname=bin\gsprint64.dll .\bin\Release\gsprint64.dll
- File /oname=bin\mupdfnet64.dll .\bin\Release\mupdfnet64.dll
- File /oname=bin\gsdll64.dll .\gslib\gsdll64.dll
-${Else}
- File /oname=bin\gsprint32.dll .\bin\Release\gsprint32.dll
- File /oname=bin\mupdfnet32.dll .\bin\Release\mupdfnet32.dll
- File /oname=bin\gsdll32.dll .\gslib\gsdll32.dll
-${EndIf}
-File /oname=bin\gsview.exe .\bin\Release\gsview.exe
-File /oname=resources\pageCBZ.ico .\Resources\pageCBZ.ico
-File /oname=resources\pageEPS.ico .\Resources\pageEPS.ico
-File /oname=resources\pagePS.ico .\Resources\pagePS.ico
-File /oname=resources\pagePDF.ico .\Resources\pagePDF.ico
-File /oname=resources\pageXPS.ico .\Resources\pageXPS.ico
-File /oname=resources\pageOXPS.ico .\Resources\pageOXPS.ico
-File /oname=resources\pagePNG.ico .\Resources\pagePNG.ico
-File /oname=resources\pageJPG.ico .\Resources\pageJPG.ico
-
-${If} ${RunningX64}
- SetRegView 64
-${EndIf}
-
-WriteRegStr HKEY_LOCAL_MACHINE "Software\Artifex Software\gsview\${VERSION}" "" "$INSTDIR"
-WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "DisplayName" "gsview"
-WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "UninstallString" '"$INSTDIR\uninstgsview.exe"'
-WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "Publisher" "Artifex Software Inc."
-WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "HelpLink" "http://www.ghostscript.com/"
-WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "URLInfoAbout" "http://www.ghostscript.com/"
-WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "DisplayVersion" "${VERSION}"
-;WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "NoModify" "1"
-WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "NoRepair" "1"
-
-; The file associations
-!insertmacro APP_ASSOCIATE "pdf" "gsview.pdf" "PDF Document" "$INSTDIR\resources\pagePDF.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\""
-!insertmacro APP_ASSOCIATE "ps" "gsview.ps" "Postscript Document" "$INSTDIR\resources\pagePS.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\""
-!insertmacro APP_ASSOCIATE "xps" "gsview.xps" "XPS Document" "$INSTDIR\resources\pageXPS.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\""
-!insertmacro APP_ASSOCIATE "oxps" "gsview.oxps" "Open XPS Document" "$INSTDIR\resources\pageOXPS.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\""
-!insertmacro APP_ASSOCIATE "cbz" "gsview.cbz" "CBZ Document" "$INSTDIR\resources\pageCBZ.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\""
-!insertmacro APP_ASSOCIATE "jpg" "gsview.jpg" "JPG Image" "$INSTDIR\resources\pageJPG.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\""
-!insertmacro APP_ASSOCIATE "png" "gsview.png" "PNG Image" "$INSTDIR\resources\pagePNG.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\""
-!insertmacro APP_ASSOCIATE "eps" "gsview.eps" "Encapsulated Postscript" "$INSTDIR\resources\pageEPS.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\""
-!insertmacro UPDATEFILEASSOC
-
-; write out uninstaller
-WriteUninstaller "$INSTDIR\uninstgsview.exe"
+ ; First check if we have the proper .net installed
+ Call CheckAndDownloadDotNet45
+
+ SetOutPath "$INSTDIR"
+ CreateDirectory "$INSTDIR\bin"
+ CreateDirectory "$INSTDIR\resources"
+ ; add files / whatever that need to be installed here.
+ ${If} ${RunningX64}
+ File /oname=bin\gsprint64.dll .\bin\Release\gsprint64.dll
+ File /oname=bin\mupdfnet64.dll .\bin\Release\mupdfnet64.dll
+ File /oname=bin\gsdll64.dll .\gslib\gsdll64.dll
+ ${Else}
+ File /oname=bin\gsprint32.dll .\bin\Release\gsprint32.dll
+ File /oname=bin\mupdfnet32.dll .\bin\Release\mupdfnet32.dll
+ File /oname=bin\gsdll32.dll .\gslib\gsdll32.dll
+ ${EndIf}
+ File /oname=bin\gsview.exe .\bin\Release\gsview.exe
+ File /oname=resources\pageCBZ.ico .\Resources\pageCBZ.ico
+ File /oname=resources\pageEPS.ico .\Resources\pageEPS.ico
+ File /oname=resources\pagePS.ico .\Resources\pagePS.ico
+ File /oname=resources\pagePDF.ico .\Resources\pagePDF.ico
+ File /oname=resources\pageXPS.ico .\Resources\pageXPS.ico
+ File /oname=resources\pageOXPS.ico .\Resources\pageOXPS.ico
+ File /oname=resources\pagePNG.ico .\Resources\pagePNG.ico
+ File /oname=resources\pageJPG.ico .\Resources\pageJPG.ico
+
+ ${If} ${RunningX64}
+ SetRegView 64
+ ${EndIf}
+ WriteRegStr HKEY_LOCAL_MACHINE "Software\Artifex Software\gsview\${VERSION}" "" "$INSTDIR"
+ WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "DisplayName" "gsview"
+ WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "UninstallString" '"$INSTDIR\uninstgsview.exe"'
+ WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "Publisher" "Artifex Software Inc."
+ WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "HelpLink" "http://www.ghostscript.com/"
+ WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "URLInfoAbout" "http://www.ghostscript.com/"
+ WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "DisplayVersion" "${VERSION}"
+ WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}" "NoRepair" "1"
+
+ ; Check if Toast directory is present before doing the associations
+ StrCpy $0 0
+ StrCpy $2 0
+ ${Do}
+ EnumRegKey $1 HKCU Software\Microsoft\Windows\CurrentVersion $0
+ ${If} $1 == 'ApplicationAssociationToasts'
+ StrCpy $2 1
+ StrCpy $1 "" ; End it now as we have found the entry
+ ${EndIf}
+ IntOp $0 $0 + 1
+ ${LoopUntil} $1 == ""
+
+ ; The file associations
+ !insertmacro APP_ASSOCIATE "pdf" "gsview.pdf" "PDF Document" "$INSTDIR\resources\pagePDF.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\"" $2 $pdf
+ !insertmacro APP_ASSOCIATE "ps" "gsview.ps" "Postscript Document" "$INSTDIR\resources\pagePS.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\"" $2 $ps
+ !insertmacro APP_ASSOCIATE "xps" "gsview.xps" "XPS Document" "$INSTDIR\resources\pageXPS.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\"" $2 $xps
+ !insertmacro APP_ASSOCIATE "oxps" "gsview.oxps" "Open XPS Document" "$INSTDIR\resources\pageOXPS.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\"" $2 $oxps
+ !insertmacro APP_ASSOCIATE "cbz" "gsview.cbz" "CBZ Document" "$INSTDIR\resources\pageCBZ.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\"" $2 $cbz
+ !insertmacro APP_ASSOCIATE "jpg" "gsview.jpg" "JPG Image" "$INSTDIR\resources\pageJPG.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\"" $2 $jpg
+ !insertmacro APP_ASSOCIATE "png" "gsview.png" "PNG Image" "$INSTDIR\resources\pagePNG.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\"" $2 $png
+ !insertmacro APP_ASSOCIATE "eps" "gsview.eps" "Encapsulated Postscript" "$INSTDIR\resources\pageEPS.ico" "Open" "$INSTDIR\bin\gsview.exe $\"%1$\"" $2 $eps
+ !insertmacro UPDATEFILEASSOC
+
+ ; write out uninstaller
+ WriteUninstaller "$INSTDIR\uninstgsview.exe"
SectionEnd ; end of default section
Function .onInstSuccess
@@ -146,6 +374,15 @@ Function .onInstSuccess
FunctionEnd
Function .onInit
+ ; Again, check that we they are doing a run as administrator
+ UserInfo::GetAccountType
+ pop $0
+ ${If} $0 != "admin" ;Require admin rights
+ MessageBox mb_iconstop "Administrator rights required!"
+ SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
+ Quit
+ ${EndIf}
+
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "GhostscriptInstaller") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
@@ -154,53 +391,66 @@ Function .onInit
FunctionEnd
Function Un.onInit
-${If} ${RunningX64}
- SetRegView 64
-${EndIf}
+ ${If} ${RunningX64}
+ SetRegView 64
+ ${EndIf}
FunctionEnd
; begin uninstall settings/section
UninstallText "This will uninstall gsview from your system"
Section Uninstall
-; add delete commands to delete whatever files/registry keys/etc you installed here.
-SetShellVarContext all
-Delete "$SMPROGRAMS\gsview\gsview ${VERSION}.LNK"
-Delete "$SMPROGRAMS\gsview\Uninstall gsview ${VERSION}.LNK"
-RMDir "$SMPROGRAMS\gsview"
-Delete "$INSTDIR\uninstgsview.exe"
-
-${If} ${RunningX64}
- SetRegView 64
-${EndIf}
-
-!insertmacro APP_UNASSOCIATE "pdf" "gsview.pdf"
-!insertmacro APP_UNASSOCIATE "ps" "gsview.ps"
-!insertmacro APP_UNASSOCIATE "xps" "gsview.xps"
-!insertmacro APP_UNASSOCIATE "oxps" "gsview.oxps"
-!insertmacro APP_UNASSOCIATE "cbz" "gsview.cbz"
-!insertmacro APP_UNASSOCIATE "jpg" "gsview.jpg"
-!insertmacro APP_UNASSOCIATE "png" "gsview.png"
-
-DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Artifex Software\gsview\${VERSION}"
-DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}"
-DeleteRegKey HKEY_LOCAL_MACHINE "Software\gsview\${VERSION}"
-RMDir /r "$INSTDIR\doc"
-Delete "$INSTDIR\bin\gsprint${WINTYPE}.dll"
-Delete "$INSTDIR\bin\mupdfnet{WINTYPE}.dll"
-Delete "$INSTDIR\bin\gsdll${WINTYPE}.dll"
-Delete "$INSTDIR\bin\gsview.exe"
-Delete "$INSTDIR\resources\pageCBZ.ico"
-Delete "$INSTDIR\resources\pageEPS.ico"
-Delete "$INSTDIR\resources\pageJPG.ico"
-Delete "$INSTDIR\resources\pageOXPS.ico"
-Delete "$INSTDIR\resources\pagePDF.ico"
-Delete "$INSTDIR\resources\pagePS.ico"
-Delete "$INSTDIR\resources\pageXPS.ico"
-Delete "$INSTDIR\resources\pagePNG.ico"
-RMDir "$INSTDIR\resources"
-RMDir "$INSTDIR\bin"
-RMDir "$INSTDIR"
+ ; add delete commands to delete whatever files/registry keys/etc you installed here.
+ SetShellVarContext all
+ Delete "$SMPROGRAMS\gsview\gsview ${VERSION}.LNK"
+ Delete "$SMPROGRAMS\gsview\Uninstall gsview ${VERSION}.LNK"
+ RMDir "$SMPROGRAMS\gsview"
+ Delete "$INSTDIR\uninstgsview.exe"
+
+ ${If} ${RunningX64}
+ SetRegView 64
+ ${EndIf}
+ ; Check if Toast directory is present before doing the unassociations
+ StrCpy $0 0
+ StrCpy $2 0
+ ${Do}
+ EnumRegKey $1 HKCU Software\Microsoft\Windows\CurrentVersion $0
+ ${If} $1 == 'ApplicationAssociationToasts'
+ StrCpy $2 1
+ StrCpy $1 ""
+ ${EndIf}
+ IntOp $0 $0 + 1
+ ${LoopUntil} $1 == ""
+
+ !insertmacro APP_UNASSOCIATE "pdf" "gsview.pdf" $2
+ !insertmacro APP_UNASSOCIATE "ps" "gsview.ps" $2
+ !insertmacro APP_UNASSOCIATE "xps" "gsview.xps" $2
+ !insertmacro APP_UNASSOCIATE "oxps" "gsview.oxps" $2
+ !insertmacro APP_UNASSOCIATE "cbz" "gsview.cbz" $2
+ !insertmacro APP_UNASSOCIATE "jpg" "gsview.jpg" $2
+ !insertmacro APP_UNASSOCIATE "png" "gsview.png" $2
+
+ DeleteRegKey HKEY_CURRENT_USER "Software\Artifex Software\GSview ${Version}"
+
+ DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Artifex Software\gsview\${VERSION}"
+ DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\gsview ${VERSION}"
+ DeleteRegKey HKEY_LOCAL_MACHINE "Software\gsview\${VERSION}"
+ RMDir /r "$INSTDIR\doc"
+ Delete "$INSTDIR\bin\gsprint${WINTYPE}.dll"
+ Delete "$INSTDIR\bin\mupdfnet{WINTYPE}.dll"
+ Delete "$INSTDIR\bin\gsdll${WINTYPE}.dll"
+ Delete "$INSTDIR\bin\gsview.exe"
+ Delete "$INSTDIR\resources\pageCBZ.ico"
+ Delete "$INSTDIR\resources\pageEPS.ico"
+ Delete "$INSTDIR\resources\pageJPG.ico"
+ Delete "$INSTDIR\resources\pageOXPS.ico"
+ Delete "$INSTDIR\resources\pagePDF.ico"
+ Delete "$INSTDIR\resources\pagePS.ico"
+ Delete "$INSTDIR\resources\pageXPS.ico"
+ Delete "$INSTDIR\resources\pagePNG.ico"
+ RMDir "$INSTDIR\resources"
+ RMDir "$INSTDIR\bin"
+ RMDir "$INSTDIR"
SectionEnd ; end of uninstall section
; From http://nsis.sourceforge.net/Download_and_Install_dotNET_45
@@ -215,8 +465,8 @@ Function CheckAndDownloadDotNet45
Var /GLOBAL dotNET_CMD_LINE
Var /GLOBAL EXIT_CODE
- # We are reading a version release DWORD that Microsoft says is the documented
- # way to determine if .NET Framework 4.5 is installed
+ # We are reading a version release DWORD that Microsoft says is the documented
+ # way to determine if .NET Framework 4.5 is installed
ReadRegDWORD $dotNET45IsThere HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Release"
IntCmp $dotNET45IsThere 378389 is_equal is_less is_greater
@@ -266,18 +516,16 @@ Function CheckAndDownloadDotNet45
IfFileExists "$EXEPATH\components\dotNET45Full.exe" do_local_install do_network_install
do_local_install:
- # .NET Framework found on the local disk. Use this copy
-
+ # .NET Framework found on the local disk. Use this copy
ExecWait '"$EXEPATH\components\dotNET45Full.exe" $dotNET_CMD_LINE' $EXIT_CODE
Goto is_reboot_requested
-
# Now, let's Download the .NET
+
do_network_install:
-
Var /GLOBAL dotNetDidDownload
NSISdl::download "http://go.microsoft.com/fwlink/?LinkId=225704" "$TEMP\dotNET45Web.exe" $dotNetDidDownload
-
StrCmp $dotNetDidDownload success fail
+
success:
ExecWait '"$TEMP\dotNET45Web.exe" $dotNET_CMD_LINE' $EXIT_CODE
Goto is_reboot_requested