#include <FileConstants.au3>
#include <StringConstants.au3>
; files
$resource = ''
$resource &= create_res('demo.jpg' , '$pic0') ; jpeg
$resource &= create_res('demo.bmp' , '$pic1') ; bmp
;$resource &= create_res('wait.gif' , '$pic2') ; gif
$fw = FileOpen('my_resource.au3', $FO_OVERWRITE+$FO_BINARY)
If $fw = -1 Then Exit
FileWrite($fw, $resource)
FileClose($fw)
msgbox(0, @ComputerName, 'Create res ok!')
Func create_res($file, $var)
$fh = FileOpen($file, $FO_BINARY)
If $fh = -1 Then
MsgBox(1, 1, 'File read error: ' & $file)
Exit
EndIf
$res = FileRead($fh)
FileClose($fh)
$arr = StringRegExp($res, '(.{1,1024})', $STR_REGEXPARRAYGLOBALMATCH)
For $i = 0 To UBound($arr) -1
If $i = 0 Then
$res = $var & ' = "' & $arr[$i] & '"' & @CRLF
Else
$res&= $var & ' &= "' & $arr[$i] & '"' & @CRLF
EndIf
Next
Return($res)
EndFunc