binghc
发表于 2010-11-15 13:50:20
回复 60# afan
好的,我回头再仔细看看你的帖子
3mile
发表于 2010-11-15 13:54:53
回复 57# binghc
下面是_FileCountLines函数的源码.
这几句很说明问题: If StringInStr($sFileContent, @LF) Then
$aTmp = StringSplit(StringStripCR($sFileContent), @LF)
ElseIf StringInStr($sFileContent, @CR) Then
$aTmp = StringSplit($sFileContent, @CR)
Else
......
Func _FileCountLines($sFilePath)
Local $hFile = FileOpen($sFilePath, $FO_READ)
If $hFile = -1 Then Return SetError(1, 0, 0)
Local $sFileContent = StringStripWS(FileRead($hFile), 2)
FileClose($hFile)
Local $aTmp
If StringInStr($sFileContent, @LF) Then
$aTmp = StringSplit(StringStripCR($sFileContent), @LF)
ElseIf StringInStr($sFileContent, @CR) Then
$aTmp = StringSplit($sFileContent, @CR)
Else
If StringLen($sFileContent) Then
Return 1
Else
Return SetError(2, 0, 0)
EndIf
EndIf
Return $aTmp
EndFunc ;==>_FileCountLines
binghc
发表于 2010-11-15 14:28:54
回复 62# 3mile
谢谢哈!我都忘了_FileCountLines()也是一个自定义函数(准确的说是系统提供的自定义函数)
回头研究研究这个函数
lchl0588
发表于 2010-11-15 15:11:57
你的问题,跟这个帖类似点之开门他也是读文本!!!还有一点也能证明:
例: 假如从注册表直接导出注册表部分,如果用AU3 来读写的话,原文件可能直接拿来用吗?肯定是:否!!
这种情况跟你的情况类似!!
偶解决方法是:在文本带文字的最后一行都回车一下,最后一行是空行!
当然也可以从代码改进,带文字的最后一行,未切换行,故未有@CF等等之类的符号。所以代码未针对此做判断,导致后来的..................
binghc
发表于 2010-11-15 15:36:32
回复 64# lchl0588
可以读啊!
lchl0588
发表于 2010-11-15 15:42:06
回复 65# binghc
不好意思,算我没说清楚!!!,用AU3 书写方式来导入导出注册表,那AU3代码跟文本中一样吗?
binghc
发表于 2010-11-15 16:51:27
回复 66# lchl0588
用AU3 书写方式来导入导出注册表,那AU3代码跟文本中一样吗?
什么意思?没看懂
kn007
发表于 2010-11-15 17:37:29
回复lchl0588
什么意思?没看懂
binghc 发表于 2010-11-15 16:51 <a target=_blank href="http://www.autoitx.com/images/common/back.gif"><img style="border:1px solid black" alt="http://www.autoitx.com/images/common/back.gif" src="http://www.autoitx.com/images/common/back.gif"></a>
就是说REG2Au3吧。。。(个人认为)
b比如文本是:Windows Registry Editor Version 5.00
;添加键
]
;添加默认项
@="Default"
;添加字符串项
"\"a-b\"="="\"a!@#$%^&*()_+-=[]{};'\\:\"|,./<>?b\"="
;删除项
"DelMe"=-
;删除键
[-HKEY_CURRENT_USER\Software\["a-b"= 'a-b']]
;其他键值测试
]
@=""
"字符串值"="字符串"
"DWORD值"=dword:12345678
"二进制值"=hex:31,32,33,34,35,36,37,38,39,30
"可扩展字符串值"=hex(2):ef,53,69,62,55,5c,57,5b,26,7b,32,4e,00,00
"多行字符串值"=hex(7):57,5b,26,7b,32,4e,31,00,00,00,57,5b,26,7b,32,4e,32,00,00,00,57,\
5b,26,7b,32,4e,33,00,00,00,57,5b,26,7b,32,4e,34,00,00,00,00,00
;错误行测试
]
@=""
"字符串值"="字符串"
"DWORD值"=dword:12345678
;错误行测试
]
@='Default'
"字符串值"="字符串"字符串
"DWORD值"=dword:1234567890
"二进制值"=hex:31,32,33,34,35,36,37,38,39,30,0 ,0 ,00,000, 0,00
"可扩展字符串值"=hex(2):ef,53,69, 62, 55,5c,57, 5b,26,7b,32,4e,00,00,0 ,0,0 ,00 ,00 ,0 ,0
"多行字符串值"=hex(7):57,5b,26,7b, 32,4e,31,00,00,00,57, 5b,26, 7b, 32, 4e,32,00,00,00,57,\
5b,26,7b,32,4e,33,00,00, 00,57,5b,26,7b,32,4e,34,00,0,0,0,00,0 , 0,0, 00 , 0
"二进制值"=hex:zz,zz,zz,zz,zz,31,32,33,34,35,36,37,38,39,30
"可扩展字符串值"=hex(2):zz,zz,zz,zz,zz,ef,53,69,62,55,5c,57,5b,26,7b,32,4e,00,00
"多行字符串值"=hex(7):zz,zz,zz,zz,zz,57,5b,26,7b,32,4e,31,00,00,00,57,5b,26,7b,32,4e,32,00,00,00,57,\
5b,26,7b,32,4e,33,00,00,00,57,5b,26,7b,32,4e,34,00,00,00,00,00
Au3是:
;添加键
RegWrite("HKEY_CURRENT_USER\Software\[""a-b""= 'a-b']")
;添加默认项
RegWrite("HKEY_CURRENT_USER\Software\[""a-b""= 'a-b']", "", "REG_SZ", "Default")
;添加字符串项
RegWrite("HKEY_CURRENT_USER\Software\[""a-b""= 'a-b']", """a-b""=", "REG_SZ", """a!@#$%^&*()_+-=[]{};'\:""|,./<>?b""=")
;删除项
RegDelete("HKEY_CURRENT_USER\Software\[""a-b""= 'a-b']", "DelMe")
;删除键
RegDelete("HKEY_CURRENT_USER\Software\[""a-b""= 'a-b']")
;其他键值测试
RegWrite("HKEY_CURRENT_USER\Software\")
RegWrite("HKEY_CURRENT_USER\Software\", "", "REG_SZ", "")
RegWrite("HKEY_CURRENT_USER\Software\", "字符串值", "REG_SZ", "字符串")
RegWrite("HKEY_CURRENT_USER\Software\", "DWORD值", "REG_DWORD", "0x12345678")
RegWrite("HKEY_CURRENT_USER\Software\", "二进制值", "REG_BINARY", "31323334353637383930")
RegWrite("HKEY_CURRENT_USER\Software\", "可扩展字符串值", "REG_EXPAND_SZ", "可扩展字符串")
RegWrite("HKEY_CURRENT_USER\Software\", "多行字符串值", "REG_MULTI_SZ", "字符串1" & @LF & "字符串2" & @LF & "字符串3" & @LF & "字符串4")
;错误行测试
; Error - ]
; Error - @=""
; Error - "字符串值"="字符串"
; Error - "DWORD值"=dword:12345678
;错误行测试
RegWrite("HKEY_CURRENT_USER\Software\")
; Error - @='Default'
; Error - "字符串值"="字符串"字符串
; Error - DWORD值=REG_DWORD:1234567890
; Error - 二进制值=REG_BINARY:31,32,33,34,35,36,37,38,39,30,0 ,0 ,00,000, 0,00
; Error - 可扩展字符串值=REG_EXPAND_SZ:ef,53,69, 62, 55,5c,57, 5b,26,7b,32,4e,00,00,0 ,0,0 ,00 ,00 ,0 ,0
RegWrite("HKEY_CURRENT_USER\Software\", "多行字符串值", "REG_MULTI_SZ", "字符串1" & @LF & "字符串2" & @LF & "字符串3" & @LF & "字符串4" & @LF && @LF )
; Error - 二进制值=REG_BINARY:zz,zz,zz,zz,zz,31,32,33,34,35,36,37,38,39,30
; Error - 可扩展字符串值=REG_EXPAND_SZ:zz,zz,zz,zz,zz,ef,53,69,62,55,5c,57,5b,26,7b,32,4e,00,00
; Error - 多行字符串值=REG_MULTI_SZ:zz,zz,zz,zz,zz,57,5b,26,7b,32,4e,31,00,00,00,57,5b,26,7b,32,4e,32,00,00,00,57,5b,26,7b,32,4e,33,00,00,00,57,5b,26,7b,32,4e,34,00,00,00,00,00
binghc
发表于 2010-11-15 18:26:19
本帖最后由 binghc 于 2010-11-15 18:28 编辑
回复 68# kn007
啊~版主(Administrator超级管理员?)辛苦了,不过看得我头都大了
本人对注册表没什么研究。。。。{:face (394):}
youarezz
发表于 2010-11-21 22:00:45
来看看。。。。。。。