Continues a stream search
#include <WinAPIFiles.au3>
_WinAPI_FindNextStream ( $hSearch, $tData )
$hSearch | The search handle returned by a previous call to the _WinAPI_FindFirstStream() function. |
$tData | A $tagWIN32_FIND_STREAM_DATA structure or a pointer to it that receives information about the stream. |
Success: | True. |
Failure: | False and sets the @error flag to non-zero, @extended flag may contain the system error code. |
If the function fails because no more streams can be found, the @extended flag will contain ERROR_HANDLE_EOF (38) system error code.
This function requires Windows Vista or later.
Search FindNextStreamW in MSDN Library.
#include <MsgBoxConstants.au3>
#include <WinAPIError.au3>
#include <WinAPIFiles.au3>
#include <WinAPIHObj.au3>
#include <WinAPIMem.au3>
#include <WinAPIMisc.au3>
#include <WinAPIShPath.au3>
_Example()
Func _Example()
Local Const $sTempFile = @TempDir & '\Test.txt'
; Check NTFS file system
If StringCompare(DriveGetFileSystem(_WinAPI_PathStripToRoot($sTempFile)), 'NTFS') Then
MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', 'The file must be on an NTFS file system volume.')
Exit
EndIf
Local $sName, $iBytes, $pData, $hFile
; Create text file with three alternative streams named AS1, AS2, and AS3 respectively
For $i = 0 To 3
If $i Then
$pData = _WinAPI_CreateString('Alternative stream ' & $i)
$sName = ':AS' & $i
Else
$pData = _WinAPI_CreateString('Main stream')
$sName = ''
EndIf
$hFile = _WinAPI_CreateFile($sTempFile & $sName, 1, 4)
_WinAPI_WriteFile($hFile, $pData, _WinAPI_GetMemorySize($pData) - 2, $iBytes)
_WinAPI_CloseHandle($hFile)
_WinAPI_FreeMemory($pData)
Next
; Enumerate all existing streams in the file and read text data from each stream
$pData = _WinAPI_CreateBuffer(1024)
Local $tFSD = DllStructCreate($tagWIN32_FIND_STREAM_DATA)
Local $hSearch = _WinAPI_FindFirstStream($sTempFile, $tFSD)
Local $iSize
While Not @error
$sName = DllStructGetData($tFSD, 'StreamName')
$iSize = DllStructGetData($tFSD, 'StreamSize')
$hFile = _WinAPI_CreateFile($sTempFile & $sName, 2, 2, 6)
_WinAPI_ReadFile($hFile, $pData, $iSize, $iBytes)
_WinAPI_CloseHandle($hFile)
ConsoleWrite(StringFormat('%10s (%s bytes) - %s', $sName, $iSize, _WinAPI_GetString($pData)) & @CRLF)
_WinAPI_FindNextStream($hSearch, $tFSD)
WEnd
Switch @extended
Case 38 ; ERROR_HANDLE_EOF
Case Else
MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
EndSwitch
_WinAPI_FindClose($hSearch)
_WinAPI_FreeMemory($pData)
FileDelete($sTempFile)
EndFunc ;==>_Example