Zedna Posted July 25, 2008 Share Posted July 25, 2008 (edited) I have sent proposition for this new UDF to Gary today.So here it is.Example:expandcollapse popup#include <WinAPI.au3> Global $sFile, $hFile, $sText, $nBytes, $tBuffer ; 1) create file and write data to it $sFile = @ScriptDir & '\test.txt' $sText = 'abcdefghijklmnopqrstuvwxyz' $tBuffer = DLLStructCreate("byte[" & StringLen($sText) & "]") DLLStructSetData($tBuffer, 1, $sText) $hFile = _WinAPI_CreateFile($sFile, 1) _WinAPI_WriteFile($hFile, DLLStructGetPtr($tBuffer), StringLen($sText), $nBytes) _WinAPI_CloseHandle($hFile) ConsoleWrite('1) ' & FileRead($sFile) & @LF) ; 2) read 6 bytes from posision 3 $tBuffer = DLLStructCreate("byte[6]") $hFile = _WinAPI_CreateFile($sFile, 2, 2) _WinAPI_SetFilePointer($hFile, 3) _WinAPI_ReadFile($hFile, DLLStructGetPtr($tBuffer), 6, $nBytes) _WinAPI_CloseHandle($hFile) $sText = BinaryToString(DLLStructGetData($tBuffer, 1)) ConsoleWrite('2) ' & $sText & @LF) ; 3) write previously read 6 bytes from posision 3 to the same position but in UpperCase DLLStructSetData($tBuffer, 1, StringUpper($sText)) $hFile = _WinAPI_CreateFile($sFile, 2, 4) _WinAPI_SetFilePointer($hFile, 3) _WinAPI_WriteFile($hFile, DLLStructGetPtr($tBuffer), 6, $nBytes) _WinAPI_CloseHandle($hFile) $tBuffer = 0 ConsoleWrite('3) ' & FileRead($sFile) & @LF) ; 4) truncate file size to 12 bytes $hFile = _WinAPI_CreateFile($sFile, 2, 4) _WinAPI_SetFilePointer($hFile, 12) _WinAPI_SetEndOfFile($hFile) _WinAPI_CloseHandle($hFile) ConsoleWrite('4) ' & FileRead($sFile) & @LF)All packed in one file as attachment:EDIT: This is included in AutoIt from 3.2.13.6 versionEDIT2: Removed UDF code from post because now it's in AutoIt standard incudesudf_zedna.zip Edited August 4, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search 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