写的很简单,对付着用吧。
#include <array.au3>
#include <WinAPI.au3>
Local $File_Name,$Hfile,$File_Content,$File_Size
Local $Obj_File,$obj_hfile,$nBytes
$File_Name=FileOpenDialog("输入要转换的文件",@ScriptDir,"所有文件(*.*)")
If Not @error Then
$Obj_File=@ScriptDir&'\temp.au3'
$Hfile=FileOpen($File_Name,16)
$File_Content=FileRead($Hfile)
$File_Size=BinaryLen($File_Content)
FileClose($Hfile)
EndIf
$Output_Filename=StringRegExpReplace($File_Name,'(.+\\)(.*$)','\2')
$Bin=StringTrimLeft($File_Content,2)
FileWrite($Obj_File,'$str="0x"'&@CRLF)
FileWrite($Obj_File,'$str&="'&$Bin&'"'&@CRLF)
FileWrite($Obj_File,'$len=Binary($str)'&@CRLF)
FileWrite($Obj_File,'$file=FileOpen(@scriptDir&"\'&$Output_Filename&'",18)'&@CRLF)
FileWrite($Obj_File,'FileWrite($file, $str)'&@CRLF)
FileWrite($Obj_File,'FileClose($file)')
MsgBox(0,"成功","成功写入"&$Obj_File)
|