我尝试为我的应用程序创建包,我可以为该应用程序创建注册表项,但仅适用于字符串类型:
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"如何创建多字符串值?
发布于 2016-12-30 07:38:42
我刚刚向NSIS添加了对WriteRegMultiStr的基本支持,但您必须等待NSISv3.02使用它。
同时,您可以:
对于系统插件(我的代码或this from the Wiki) ),请按照idleberg
Regedit.exe /S file.reg对系统插件所建议的方式使用Regedit.exe /S file.regNSIS v3.0+:
!include WinCore.nsh
!include Util.nsh
!include LogicLib.nsh
!macro RegMultiStr_Free list
System::Free ${list}
!macroend
!macro RegMultiStr_Begin list new
StrLen ${list} `${new}`
System::Call '*(&t${list}s,&t1"",&t1"")p.s' `${new}`
Pop ${list}
!macroend
!macro RegMultiStr_Append list new
Push ${list}
Push `${new}`
!insertmacro CallArtificialFunction RegMultiStr_AppendImp
Pop ${list}
!macroend
!macro RegMultiStr_AppendImp
System::Store S
Pop $2 ; New string
Pop $1 ; List
System::Call KERNEL32::GlobalSize(pr1)i.r3 ; $3 = TotSize
StrLen $4 $2
System::Call '*(&i$3,&t$4,&t1)p.r5'
System::Copy $5 $1
IntOp $3 $3 - ${NSIS_CHAR_SIZE}
System::Call '*$5(&i$3,&t$4s,&t1"",&t1"")' $2
!insertmacro RegMultiStr_Free $1
Push $5
System::Store L
!macroend
!macro RegMultiStr_Write hk subkey name list
Push ${hk}
Push `${subkey}`
Push `${name}`
Push ${list}
!insertmacro CallArtificialFunction RegMultiStr_WriteImp
!macroend
!macro RegMultiStr_WriteImp
System::Store S
Pop $4 ; List
Pop $3 ; Name
Pop $2 ; SubKey
Pop $1 ; Root HK
System::Call 'ADVAPI32::RegCreateKey(ir1, tr2, *p0r5)i.r0' ; $5 = HKEY
${If} $0 = 0
StrCpy $7 $4 ; list items pointer
loop:
System::Call KERNEL32::lstrlen(t)(pr7)i.r6
IntOp $0 $0 + ${NSIS_CHAR_SIZE} ; \0
${IfThen} $6 = 0 ${|} Goto Write ${|}
!if "${NSIS_CHAR_SIZE}" > 1
IntOp $6 $6 * ${NSIS_CHAR_SIZE}
!endif
IntOp $0 $0 + $6
IntOp $6 $6 + ${NSIS_CHAR_SIZE} ; \0
${IntPtrOp} $7 $7 + $6
Goto loop
write:
System::Call 'ADVAPI32::RegSetValueEx(pr5, tr3, i0, i7, pr4, ir0)i.r0'
System::Call 'ADVAPI32::RegCloseKey(pr5)'
${EndIf}
System::Store L
!macroend
!include WinCore.nsh
Section
!insertmacro RegMultiStr_Begin $0 "Foo"
!insertmacro RegMultiStr_Append $0 "Bar"
!insertmacro RegMultiStr_Write ${HKEY_CURRENT_USER} "Software\NSIS\Test" "MultiStrTest" $0
!insertmacro RegMultiStr_Append $0 "B a z"
!insertmacro RegMultiStr_Write ${HKEY_CURRENT_USER} "Software\NSIS\Test" "Test 2" $0
!insertmacro RegMultiStr_Free $0
SectionEndhttps://stackoverflow.com/questions/41357768
复制相似问题