Как прочитать первые 28 байт файла?
Код:
#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$gui = GUICreate("", 387, 43, -1, -1)
$filepath = GUICtrlCreateInput("", 8, 8, 209, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
$filepatch = GUICtrlCreateButton("proceed", 304, 8, 75, 25)
$filechoose = GUICtrlCreateButton("choose", 224, 8, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$orig = BinaryToString('0x494F4152437C7665722E312E3334E22C9C8ABBEEF0F60C6559AE6C01')
$repl = BinaryToString('0x4D5A90000300000004000000FFFF0000B80000000000000040000000')
$reg = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramW6432Dir")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $filepatch
$readfile = FileRead(GUICtrlRead($filepath))
$readfile = StringReplace($readfile, $orig, $repl)
If @extended > 0 Then
$fo = FileOpen($file[0], 2)
FileWrite($fo, $readfile)
FileClose($fo)
MsgBox(0, 'done', 'file patched')
Else
MsgBox(0, 'error', 'wrong file')
EndIF
Case $filechoose
$fod = FileOpenDialog('', @ScriptDir & '\', '(*.io)')
If @error Then
MsgBox(0, '', 'no file were selected')
FileChangeDir(@ScriptDir)
Else
FileChangeDir(@ScriptDir)
GUICtrlSetData($filepath, $fod)
$mask = '\\([^\\]+)$'
$file = StringRegExp($fod, $mask, 1)
EndIf
EndSwitch
WEnd