Sign in to follow this  
Followers 0

Bin File Include In Script Or Via Network

1 post in this topic

this is my code to include a bin file(or any file you wan) in a script under the format of a array variable!

to start you have to use this code to create the au3 file format from the source file can be Bin/TXT file.

i suggest you compile it before! and make your modification! i code this on the fire! just to demontrate example of implememting bin file!

a similair methode can be use to transfer file over network in au3 script!

#include <string.au3>

Global $biPath = @ScriptDir&"\"
Global $biFileName
Global $biFileAu3 = "BinIncludebe.au3"

$biFileToInclude = FileOpenDialog ( "Source", $biPath, "All Files (*.*)", 3)
if not @error Then 
    $biBSPosition = StringInStr($biFileToInclude,"\",1,-1)
    $biFileName = StringTrimLeft($biFileToInclude,$biBSPosition)

$biNombreDeByte = FileGetSize($biFileToInclude)
if @error then msgbox(0,"Error","Unable To Read File")
if $biNombreDeByte > 2000 Then
    $biNombreIndex = Round($biNombreDeByte/2000,0)+1
    Dim $biFileRead[$biNombreIndex+1]
    $biFileRead[0] = $biNombreIndex
    Dim $biFileRead[2]
    $biFileRead[0] = 1

for $bix = 1 to $biFileRead[0]
    $biFileRead[$bix] = _StringToHex(fileread($biFileHandle,2000))
    if @error then msgbox(0,"Error","Unable To Read File")

filewrite($biFileHandle,"Global $biFileName = """&$biFileName&""""&@CRLF)
filewrite($biFileHandle,"Dim $biBinInclude["&$biFileRead[0]+1&"]"&@CRLF)
filewrite($biFileHandle,"$biBinInclude[0] = "&$biNombreIndex&@CRLF)
for $bix = 1 to $biFileRead[0]
    filewrite($biFileHandle,"$biBinInclude["&$bix&"] = """&$biFileRead[$bix]&""""&@CRLF)

this code will create you a au3 file.

after you simply add this to your script

#include "BinIncludebe.au3"; this is the file created by the first script
#Include <string.au3>

$biFileHandle = FileOpen($biFileName,2)
for $bix = 1 to $biBinInclude[0]

i tested it with 3 file

1- EXE file of 6 Kbytes = 5 Secondes To Compute

2- ZIP File of 191 Kbytes = 9 Secondes to Compute

3- AVI File of 43 MBytes = About 5 Minute

it not very impressive with big file! but for small file like your script! or for implemanting ini file

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0