teadrinker wrote: ↑12 Apr 2021, 14:46
Try this:
Code: Select all
file := FileOpen(myfile , "r")
file.Pos := 0
SafeArray := ComObjArray(VT_UI1 := 0x11, file.Length)
file.RawRead(NumGet(ComObjValue(SafeArray) + 8 + A_PtrSize), file.Length)
file.Close()
MsgBox, % "The first byte: " . Format("{:#x}", SafeArray[0]) ; <-- null based array
Thanks, that's very fast, but ultimately not useful to me as I need the array to be compatible with all the standard ahk array/object funcs.
Copying it into an ahk array takes around 7 seconds with setbatchlines -1, which is not too bad, but then my original code does it in 14 seconds with setbatchlines -1.
Copying it to an ahk array causes memory usage to increase from 7MB to 470MB. It seems that can be reduced to 280MB with filebytes.SetCapacity(A_Index, 4). But if I go lower than 4, the byte becomes truncated. I guess Format("{:02X}", NumGet(byte, "int") is increasing the size to 4 bytes or something?
edit: I adapted my script to use ComObjArray's funcs, so it's all good
I am still curious to know if there is a way to do it in ahk's standard library.