本帖最后由 caodongchun 于 2010-4-23 00:39 编辑
FileInstall 经常报毒!
需要安装文件时最好还是二进制现写
SQLite.dll.au3就是一个很好的例子!
那么存在一个问题:如何将二进制写入AU3,这里有一个实例#include<array.au3>
Func _FileToAu3($sSoure, $sDest)
$n = 0
$sfile = FileOpen($sSoure, 16)
$sbin = String(FileRead($sfile))
Dim $sarray[1]
While 1
If StringLen($sbin) - 4082 * $n < 0 Then ExitLoop
If $n = 0 Then
$sarray[0] = StringMid($sbin, 1, 4082)
Else
_ArrayAdd($sarray, StringMid($sbin, 4082 * $n + 1, 4082))
EndIf
$n = $n + 1
WEnd
$sDFile = FileOpen($sDest, 2)
FileWrite($sDFile, 'Func _Au3ToFile()' & @CRLF)
FileWrite($sDFile, "local $bin" & @CRLF)
For $x = 0 To UBound($sarray) - 1
FileWrite($sDFile, "$bin &='" & $sarray[$x] & "'" & @CRLF)
Next
FileWrite($sDFile, ' Return Binary($bin)' & @CRLF)
FileWrite($sDFile, 'EndFunc' & @CRLF)
EndFunc ;==>_FileToAu3
上面是UDF,下面是应用:#include"FileToAu3.au3"
_FileToAu3('C:\Program Files\WinRAR\rar.exe','rar.exe.au3')
#include"rar.exe.au3"
$bin = _Au3ToFile()
$file=FileOpen('rar.exe',18)
FileWrite($file,$bin)
FileClose($file)
|