Reference/SetRegView

From NSIS Wiki
Jump to navigationJump to search

SetRegView

32|64|lastused

Sets the registry view affected by registry commands. On Windows x64 there are two views. One for 32-bit applications and one for x64 applications. By default, 32-bit applications running on x64 systems under WOW64 have access only to the 32-bit view. Using SetRegView 64 allows the installer to access keys in the x64 view of the registry.

Affects DeleteRegKey, DeleteRegValue, EnumRegKey, EnumRegValue, ReadRegDWORD, ReadRegStr, WriteRegBin, WriteRegDWORD, WriteRegStr and WriteRegExpandStr.

Does not affect InstallDirRegKey. Instead, the registry can be read using ReadRegStr in .onInit.

SetRegView 32
ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion ProgramFilesDir
DetailPrint $0 # prints C:\Program Files (x86)
SetRegView 64
ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion ProgramFilesDir
DetailPrint $0 # prints C:\Program Files
Function .onInit
  SetRegView 64
  ReadRegStr $INSTDIR HKLM Software\NSIS ""
  SetRegView 32
FunctionEnd