关于 NSIS 写入注册表的问题, REG_MULTI_SZ 类型
2006-12-20 09:24
477 查看
作者: RESTOOLS 来源:RESTOOLS 时间:2006-08-06 点击:1107
在官方论坛找到了这个插件,传上来共享,这个插件不错,支持很多类型的键值的读取和写入,真的非常不错,对于经常跟注册表打交道的汉化软件安装程序,一定要备一个
文件下载: 点击这里下载
至于不用插件,纯用脚本写的对于注册表这种类型的值的写入,以下是一个参考脚本例子。
引用来自 Untitled01,2006-5-13 2:36:24
OutFile "REG_MULTI_SZ_writer.exe"
Name "REG_MULTI_SZ"
ShowInstDetails show
!define HKEY_CLASSES_ROOT 0x80000000
!define HKEY_CURRENT_USER 0x80000001
!define HKEY_LOCAL_MACHINE 0x80000002
!define HKEY_USERS 0x80000003
!define HKEY_PERFORMANCE_DATA 0x80000004
!define HKEY_PERFORMANCE_TEXT 0x80000050
!define HKEY_PERFORMANCE_NLSTEXT 0x80000060
!define HKEY_CURRENT_CONFIG 0x80000005
!define HKEY_DYN_DATA 0x80000006
!define KEY_QUERY_VALUE 0x0001
!define KEY_SET_VALUE 0x0002
!define KEY_create_SUB_KEY 0x0004
!define KEY_ENUMERATE_SUB_KEYS 0x0008
!define KEY_NOTIFY 0x0010
!define KEY_create_LINK 0x0020
!define REG_NONE 0
!define REG_SZ 1
!define REG_EXPAND_SZ 2
!define REG_BINARY 3
!define REG_DWORD 4
!define REG_DWORD_LITTLE_ENDIAN 4
!define REG_DWORD_BIG_ENDIAN 5
!define REG_LINK 6
!define REG_MULTI_SZ 7
!define RegcreateKey "Advapi32::RegcreateKeyA(i, t, *i) i"
!define RegSetValueEx "Advapi32::RegSetValueExA(i, t, i, i, i, i) i"
!define RegCloseKey "Advapi32::RegCloseKeyA(i) i"
####### Edit this!
!define ROOT_KEY "${HKEY_LOCAL_MACHINE}"
!define SUB_KEY "SOFTWARE/NSIS"
!define VALUE "RegMultiSzTest"
!define DATA_1 "First string"
!define DATA_2 "Second string"
####### Stop editing
Section "Write"
SetPluginUnload alwaysoff
; create a buffer for the multi_sz value
System::Call "*(&t${NSIS_MAX_STRLEN}) i.r1"
; Open/create the registry key
System::Call "${RegcreateKey}(${ROOT_KEY}, '${SUB_KEY}', .r0) .r9"
; Failed?
IntCmp $9 0 write
MessageBox MB_OK|MB_ICONSTOP "Can't create registry key! ($9)"
Goto noClose
write:
; Fill in the buffer with our strings
StrCpy $2 $1 ; Initial position
StrLen $9 '${DATA_1}' ; Length of first string
IntOp $9 $9 + 1 ; Plus null
System::Call "*$2(&t$9 '${DATA_1}')" ; Place the string
IntOp $2 $2 + $9 ; Advance to the next position
StrLen $9 '${DATA_2}' ; Length of second string
IntOp $9 $9 + 1 ; Plus null
System::Call "*$2(&t$9 '${DATA_2}')" ; Place the string
IntOp $2 $2 + $9 ; Advance to the next position
System::Call "*$2(&t1 '')" ; Place the terminating null
IntOp $2 $2 + 1 ; Advance to the next position
; create/write the value
IntOp $2 $2 - $1 ; Total length
System::Call "${RegSetValueEx}(r0, '${VALUE}', 0, ${REG_MULTI_SZ}, r1, r2) .r9"
; Failed?
IntCmp $9 0 done
MessageBox MB_OK|MB_ICONSTOP "Can't set key value! ($9)"
Goto done
done:
; Close the registry key
System::Call "${RegCloseKey}(r0)"
noClose:
; Clear the buffer
SetPluginUnload manual
System::Free $1
SectionEnd
在官方论坛找到了这个插件,传上来共享,这个插件不错,支持很多类型的键值的读取和写入,真的非常不错,对于经常跟注册表打交道的汉化软件安装程序,一定要备一个
文件下载: 点击这里下载
至于不用插件,纯用脚本写的对于注册表这种类型的值的写入,以下是一个参考脚本例子。
引用来自 Untitled01,2006-5-13 2:36:24
OutFile "REG_MULTI_SZ_writer.exe"
Name "REG_MULTI_SZ"
ShowInstDetails show
!define HKEY_CLASSES_ROOT 0x80000000
!define HKEY_CURRENT_USER 0x80000001
!define HKEY_LOCAL_MACHINE 0x80000002
!define HKEY_USERS 0x80000003
!define HKEY_PERFORMANCE_DATA 0x80000004
!define HKEY_PERFORMANCE_TEXT 0x80000050
!define HKEY_PERFORMANCE_NLSTEXT 0x80000060
!define HKEY_CURRENT_CONFIG 0x80000005
!define HKEY_DYN_DATA 0x80000006
!define KEY_QUERY_VALUE 0x0001
!define KEY_SET_VALUE 0x0002
!define KEY_create_SUB_KEY 0x0004
!define KEY_ENUMERATE_SUB_KEYS 0x0008
!define KEY_NOTIFY 0x0010
!define KEY_create_LINK 0x0020
!define REG_NONE 0
!define REG_SZ 1
!define REG_EXPAND_SZ 2
!define REG_BINARY 3
!define REG_DWORD 4
!define REG_DWORD_LITTLE_ENDIAN 4
!define REG_DWORD_BIG_ENDIAN 5
!define REG_LINK 6
!define REG_MULTI_SZ 7
!define RegcreateKey "Advapi32::RegcreateKeyA(i, t, *i) i"
!define RegSetValueEx "Advapi32::RegSetValueExA(i, t, i, i, i, i) i"
!define RegCloseKey "Advapi32::RegCloseKeyA(i) i"
####### Edit this!
!define ROOT_KEY "${HKEY_LOCAL_MACHINE}"
!define SUB_KEY "SOFTWARE/NSIS"
!define VALUE "RegMultiSzTest"
!define DATA_1 "First string"
!define DATA_2 "Second string"
####### Stop editing
Section "Write"
SetPluginUnload alwaysoff
; create a buffer for the multi_sz value
System::Call "*(&t${NSIS_MAX_STRLEN}) i.r1"
; Open/create the registry key
System::Call "${RegcreateKey}(${ROOT_KEY}, '${SUB_KEY}', .r0) .r9"
; Failed?
IntCmp $9 0 write
MessageBox MB_OK|MB_ICONSTOP "Can't create registry key! ($9)"
Goto noClose
write:
; Fill in the buffer with our strings
StrCpy $2 $1 ; Initial position
StrLen $9 '${DATA_1}' ; Length of first string
IntOp $9 $9 + 1 ; Plus null
System::Call "*$2(&t$9 '${DATA_1}')" ; Place the string
IntOp $2 $2 + $9 ; Advance to the next position
StrLen $9 '${DATA_2}' ; Length of second string
IntOp $9 $9 + 1 ; Plus null
System::Call "*$2(&t$9 '${DATA_2}')" ; Place the string
IntOp $2 $2 + $9 ; Advance to the next position
System::Call "*$2(&t1 '')" ; Place the terminating null
IntOp $2 $2 + 1 ; Advance to the next position
; create/write the value
IntOp $2 $2 - $1 ; Total length
System::Call "${RegSetValueEx}(r0, '${VALUE}', 0, ${REG_MULTI_SZ}, r1, r2) .r9"
; Failed?
IntCmp $9 0 done
MessageBox MB_OK|MB_ICONSTOP "Can't set key value! ($9)"
Goto done
done:
; Close the registry key
System::Call "${RegCloseKey}(r0)"
noClose:
; Clear the buffer
SetPluginUnload manual
System::Free $1
SectionEnd
相关文章推荐
- 关于NSIS 写入注册表的问题, REG_MULTI_SZ 类型
- 注册表写入REG_MULTI_SZ类型
- VBScript读取注册表中REG_MULTI_SZ类型数值的两种方法
- 关于一个模块中所有rgs文件中有注册项无法全部写入注册表的问题
- C++ 读取REG_SZ 、REG_DWORD 、REG_MULTI_SZ 类型注册表值
- 关于MysQL中写入日期类型数据失败的问题
- (转载)RegSetValueEx设置REG_SZ类型键值时要注意的问题
- 写注册表中REG_MULTI_SZ的代码,支持d2010,EM论坛里找的。
- 旧闻:windows关于产品类型注册表写入的防止机制
- 关于数据类型取值范围相关问题
- 关于java中Double类型的运算精度问题
- NSIS 关于 uninst.exe 的签名问题
- WINDOWS下操作注册表 REG_EXPAND_SZ与REG_SZ的区别
- 关于组态王的字符串写入问题:
- 关于double类型保留小数的问题收藏
- C++中关于string类型究竟能不能用cout输出的问题(转载https://www.cnblogs.com/mzct123/p/4876185.html)
- 关于Integer对象比较,和int基本类型比较的一些问题
- 关于java基础类型与引用类型内存存储问题,以及string.intern()方法(String两种创建方式的区别)
- 关于C++ variant 类型问题
- 关于java的一些小问题,list中添加对象,java基本数据类型对象