dandz Posted June 20, 2007 Share Posted June 20, 2007 Hello, i am interested, if there is any function for setting the position within a file for binary reading/writing. Thank you. Link to comment Share on other sites More sharing options...
randallc Posted June 20, 2007 Share Posted June 20, 2007 Hi._FileSetPosAPI , or included as 3rd parameter in _FileReadAPI, _FileWriteAPIeg;apitry2.au3#include "APITailRW.au3"Local $sDeskFile = @DesktopDir & "\Rhododendron.bmp", $s_File = @WindowsDir & "\Rhododendron.bmp"Local $i_FileSize = FileGetSize($s_File), $iMod = $i_FileSize - 4 * Int($i_FileSize / 4);======Read parts or tail of binary file =====in any order as Demo =================================$h_File = _FileOpenAPI ($s_File) ;_APIFileOpen$s_data2 = _FileReadAPI ($h_File, Int($i_FileSize / 4), 1 * Int($i_FileSize / 4), 1) ; read 2nd quarter file$s_data1 = _FileReadAPI ($h_File, Int($i_FileSize / 4), 0 * Int($i_FileSize / 4), 1) ; read 1st quarter file$s_data4 = _FileReadAPI ($h_File, Int($i_FileSize / 4) + $iMod, 3 * Int($i_FileSize / 4), 1) ; read 4th quarter file$s_data3 = _FileReadAPI ($h_File, Int($i_FileSize / 4), 2 * Int($i_FileSize / 4), 1) ; read 3rd quarter file$s_data = $s_data1 & $s_data2 & $s_data3 & $s_data4 ; concatenate in correct order_FileCloseAPI ($h_File);_APIFileClose;======Save binary file to desktop and open==========in any order as Demo ==================================Local $iDel=FileDelete($sDeskFile), $hb_File = _FileOpenAPI ($sDeskFile) ;_FileOpenAPI;======Set End of file related to $FileSize=================================_FileSetPosAPI ($hb_File, $i_FileSize)_FileSetEndAPI ($hb_File);======Set Data pieces================in any order as Demo ======================_FileWriteAPI ($hb_File, $s_data3, 2 * Int($i_FileSize / 4), 1);_APIFileWrite($hFile, $szData, $i_FileSetPosAPI = -1, $Option = 0)_FileWriteAPI ($hb_File, $s_data1, 0 * Int($i_FileSize / 4), 1);_APIFileWrite($hFile, $szData, $i_FileSetPosAPI = -1, $Option = 0)_FileWriteAPI ($hb_File, $s_data4, 3 * Int($i_FileSize / 4), 1);_APIFileWrite($hFile, $szData, $i_FileSetPosAPI = -1, $Option = 0)_FileWriteAPI ($hb_File, $s_data2, 1 * Int($i_FileSize / 4), 1);_APIFileWrite($hFile, $szData, $i_FileSetPosAPI = -1, $Option = 0)_FileCloseAPI ($hb_File);_FileCloseAPIShellExecuteWait($sDeskFile)FileDelete($sDeskFile)Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now