2121import easeOfAccess
2222import COMRegistrationFixes
2323import winKernel
24+ from typing import Dict , Union
2425
2526_wsh = None
2627def _getWSH ():
@@ -227,16 +228,23 @@ def removeOldProgramFiles(destPath):
227228 log .warning (f"Couldn't remove file: { path !r} " )
228229
229230
230- uninstallerRegInfo = {
231- "DisplayName" :versionInfo .name ,
232- "DisplayVersion" :versionInfo .version ,
233- "DisplayIcon" :u"{installDir}\\ images\\ nvda.ico" ,
234- "InstallDir" :u"{installDir}" ,
235- "Publisher" :versionInfo .publisher ,
236- "UninstallDirectory" :u"{installDir}" ,
237- "UninstallString" :u"{installDir}\\ uninstall.exe" ,
238- "URLInfoAbout" :versionInfo .url ,
239- }
231+ def getUninstallerRegInfo (installDir : str ) -> Dict [str , Union [str , int ]]:
232+ """
233+ Constructs a dictionary that is written to the registry for NVDA to show up
234+ in the Windows' Aps and Features overview.
235+ """
236+ return dict (
237+ DisplayName = f"{ versionInfo .name } { versionInfo .version } " ,
238+ DisplayVersion = versionInfo .version_detailed ,
239+ DisplayIcon = os .path .join (installDir , "images" , "nvda.ico" ),
240+ # EstimatedSize is in KiB
241+ EstimatedSize = getDirectorySize (installDir ) // 1024 ,
242+ InstallDir = installDir ,
243+ Publisher = versionInfo .publisher ,
244+ UninstallDirectory = installDir ,
245+ UninstallString = os .path .join (installDir , "uninstall.exe" ),
246+ URLInfoAbout = versionInfo .url ,
247+ )
240248
241249
242250def getDirectorySize (path : str ) -> int :
@@ -259,34 +267,22 @@ def registerInstallation(
259267 startOnLogonScreen : bool ,
260268 configInLocalAppData : bool = False
261269) -> None :
262- calculatedUninstallerRegInfo = uninstallerRegInfo .copy ()
263- # EstimatedSize is in KiB
264- estimatedSize = getDirectorySize (installDir )
265- log .debug (f"Estimated install size { estimatedSize } " )
266- calculatedUninstallerRegInfo .update (EstimatedSize = estimatedSize // 1024 )
270+ calculatedUninstallerRegInfo = getUninstallerRegInfo (installDir )
271+ log .debug (f"Estimated install size { calculatedUninstallerRegInfo .get ('EstimatedSize' )} " )
267272 with winreg .CreateKeyEx (
268273 winreg .HKEY_LOCAL_MACHINE ,
269274 r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NVDA" ,
270275 0 ,
271276 winreg .KEY_WRITE
272277 ) as k :
273278 for name , value in calculatedUninstallerRegInfo .items ():
274- if isinstance (value , int ):
275- winreg .SetValueEx (
276- k ,
277- name ,
278- None ,
279- winreg .REG_DWORD ,
280- value
281- )
282- else :
283- winreg .SetValueEx (
284- k ,
285- name ,
286- None ,
287- winreg .REG_SZ ,
288- value .format (installDir = installDir )
289- )
279+ winreg .SetValueEx (
280+ k ,
281+ name ,
282+ None ,
283+ winreg .REG_DWORD if isinstance (value , int ) else winreg .REG_SZ ,
284+ value
285+ )
290286 with winreg .CreateKeyEx (winreg .HKEY_LOCAL_MACHINE ,"SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ App Paths\\ nvda.exe" ,0 ,winreg .KEY_WRITE ) as k :
291287 winreg .SetValueEx (k ,"" ,None ,winreg .REG_SZ ,os .path .join (installDir ,"nvda.exe" ))
292288 with winreg .CreateKeyEx (winreg .HKEY_LOCAL_MACHINE , config .RegistryKey .NVDA .value , 0 , winreg .KEY_WRITE ) as k :
0 commit comments