SetRegView lastused 的用途是什么?
What's the purpose of SetRegView lastused?
SetRegView lastused
的目的是什么?
docs只讲32/64位的注册表视图,我懂的。
我认为它可能像 this person 一样充当堆栈,能够切换回当前正在使用的视图之前的视图。但是有人问这个问题的回答是:
No stack. Just the last one used.
在这种情况下,如果您已经在 32 位视图中,它就等同于 SetRegView 32
?这似乎不对,我错过了什么?
我的 google-fu 只让我知道了,从 Mozilla 中找到这个例子(完整脚本的片段):
; Since the Maintenance service can be installed either x86 or x64,
; always use the 64-bit registry.
${If} ${RunningX64}
; Previous versions always created the uninstall key in the 32-bit registry.
; Clean those old entries out if they still exist.
SetRegView 32
DeleteRegKey HKLM "${MaintUninstallKey}"
; Preserve the lastused value before we switch to 64.
SetRegView lastused
SetRegView 64
${EndIf}
然后在脚本后面的几个地方:
${If} ${RunningX64}
SetRegView lastused
${EndIf}
查看那里的上下文,如果您调用 SetRegView 32
,然后调用 SetRegView lastused
,这是否意味着将来使用 SetRegView lastused
将始终导致 32 位注册表视图?
不是它不是堆栈(但你可以争辩说它应该是)。简直就是上次设定的32/64状态。
SetRegView
指令被 MakeNSIS 转换为名为 EW_SETFLAG
的 NSIS 操作码,其在安装程序中的实现如下所示:
if (get_last_used)
g_exec_flags[flag] = g_exec_flags_last_used[flag] ; Restore previous
else
g_exec_flags_last_used[flag] = g_exec_flags[flag] ; Set last used
g_exec_flags[flag] = new_value ; Assign new value
这些标志也可用于 exec_flags_t 结构中的插件。
仅当您主要处理一个注册表视图但偶尔需要从另一个视图读取时才有用:
Section
SetRegView 64
ReadRegStr [=11=] HKLM "Software\Foo" "Bar"
SetRegView lastused ; We are now back to the default view (32-bit in this case)
SectionEnd
或者如果您主要使用 64 位视图:
Function .onInit
SetRegView 64
FunctionEnd
Section
SetRegView 32
ReadRegStr [=12=] HKLM "Software\Foo" "Bar"
SetRegView lastused ; We are now back to the previous view (64-bit in this case)
SectionEnd
我猜它是以这种方式实现的,因为它只是重用了其他标志使用的上次使用的功能。它还简化了事情,因为它永远不必分配更多内存。我也不知道为什么它没有记录。
SetRegView lastused
的目的是什么?
docs只讲32/64位的注册表视图,我懂的。
我认为它可能像 this person 一样充当堆栈,能够切换回当前正在使用的视图之前的视图。但是有人问这个问题的回答是:
No stack. Just the last one used.
在这种情况下,如果您已经在 32 位视图中,它就等同于 SetRegView 32
?这似乎不对,我错过了什么?
我的 google-fu 只让我知道了,从 Mozilla 中找到这个例子(完整脚本的片段):
; Since the Maintenance service can be installed either x86 or x64,
; always use the 64-bit registry.
${If} ${RunningX64}
; Previous versions always created the uninstall key in the 32-bit registry.
; Clean those old entries out if they still exist.
SetRegView 32
DeleteRegKey HKLM "${MaintUninstallKey}"
; Preserve the lastused value before we switch to 64.
SetRegView lastused
SetRegView 64
${EndIf}
然后在脚本后面的几个地方:
${If} ${RunningX64}
SetRegView lastused
${EndIf}
查看那里的上下文,如果您调用 SetRegView 32
,然后调用 SetRegView lastused
,这是否意味着将来使用 SetRegView lastused
将始终导致 32 位注册表视图?
不是它不是堆栈(但你可以争辩说它应该是)。简直就是上次设定的32/64状态。
SetRegView
指令被 MakeNSIS 转换为名为 EW_SETFLAG
的 NSIS 操作码,其在安装程序中的实现如下所示:
if (get_last_used)
g_exec_flags[flag] = g_exec_flags_last_used[flag] ; Restore previous
else
g_exec_flags_last_used[flag] = g_exec_flags[flag] ; Set last used
g_exec_flags[flag] = new_value ; Assign new value
这些标志也可用于 exec_flags_t 结构中的插件。
仅当您主要处理一个注册表视图但偶尔需要从另一个视图读取时才有用:
Section
SetRegView 64
ReadRegStr [=11=] HKLM "Software\Foo" "Bar"
SetRegView lastused ; We are now back to the default view (32-bit in this case)
SectionEnd
或者如果您主要使用 64 位视图:
Function .onInit
SetRegView 64
FunctionEnd
Section
SetRegView 32
ReadRegStr [=12=] HKLM "Software\Foo" "Bar"
SetRegView lastused ; We are now back to the previous view (64-bit in this case)
SectionEnd
我猜它是以这种方式实现的,因为它只是重用了其他标志使用的上次使用的功能。它还简化了事情,因为它永远不必分配更多内存。我也不知道为什么它没有记录。