From: Michael Curran Date: Mon, 2 Apr 2012 09:40:28 +0000 (+1000) Subject: installer: find the correct program files path in the registry. Correctly check... X-Git-Tag: jpdev130418~987^2~3 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=237f76dde865dc50a570b149b9d3ce101cf8f85e;p=nvdajp%2Fnvdajp.git installer: find the correct program files path in the registry. Correctly check to see if the desktop shortcut exists before removing in unregisterInstallation rather than just checking its containing directory. Do not hard code icon paths for any of our shortcuts as Windows probably does better finding them itself - may fix some icon issues. --- diff --git a/source/installer.py b/source/installer.py index 338f1345f..0c457e045 100644 --- a/source/installer.py +++ b/source/installer.py @@ -23,7 +23,9 @@ def _getWSH(): return _wsh defaultStartMenuFolder=versionInfo.name -defaultInstallPath=os.path.join(unicode(os.getenv("ProgramFiles")), versionInfo.name) +with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion") as k: + programFilesPath=_winreg.QueryValueEx(k, "ProgramFilesDir")[0] +defaultInstallPath=os.path.join(programFilesPath, versionInfo.name) def createShortcut(path,targetPath=None,arguments=None,iconLocation=None,workingDirectory=None,hotkey=None,prependSpecialFolder=None): wsh=_getWSH() @@ -157,8 +159,8 @@ def registerInstallation(installDir,startMenuFolder,shouldCreateDesktopShortcut, NVDAExe=os.path.join(installDir,u"nvda.exe") slaveExe=os.path.join(installDir,u"nvda_slave.exe") if shouldCreateDesktopShortcut: - createShortcut(u"nvda.lnk",targetPath=slaveExe,arguments="launchNVDA -r",iconLocation=NVDAExe+",0",hotkey="CTRL+ALT+N",workingDirectory=installDir,prependSpecialFolder="AllUsersDesktop") - createShortcut(os.path.join(startMenuFolder,"NVDA.lnk"),targetPath=NVDAExe,iconLocation=NVDAExe+",0",workingDirectory=installDir,prependSpecialFolder="AllUsersPrograms") + createShortcut(u"NVDA.lnk",targetPath=slaveExe,arguments="launchNVDA -r",hotkey="CTRL+ALT+N",workingDirectory=installDir,prependSpecialFolder="AllUsersDesktop") + createShortcut(os.path.join(startMenuFolder,"NVDA.lnk"),targetPath=NVDAExe,workingDirectory=installDir,prependSpecialFolder="AllUsersPrograms") createShortcut(os.path.join(startMenuFolder,_("NVDA Website")+".lnk"),targetPath=versionInfo.url,prependSpecialFolder="AllUsersPrograms") createShortcut(os.path.join(startMenuFolder,_("Uninstall NVDA")+".lnk"),targetPath=os.path.join(installDir,"uninstall.exe"),workingDirectory=installDir,prependSpecialFolder="AllUsersPrograms") createShortcut(os.path.join(startMenuFolder,_("Explore NVDA user configuration directory")+".lnk"),targetPath=slaveExe,arguments="exploreUserconfigPath",workingDirectory=installDir,prependSpecialFolder="AllUsersPrograms") @@ -182,10 +184,10 @@ def unregisterInstallation(forUpdate=False): except: pass wsh=_getWSH() - desktopPath=wsh.SpecialFolders("AllUsersDesktop") + desktopPath=os.path.join(wsh.SpecialFolders("AllUsersDesktop"),"NVDA.lnk") if os.path.isfile(desktopPath): try: - os.remove(os.path.join(desktopPath,"nvda.lnk")) + os.remove(desktopPath) except WindowsError: pass startMenuFolder=getStartMenuFolder()