Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/12/2015 in all areas

  1. JLogan3o13

    Cpu at 50%

    Add a short sleep, like 100ms, to keep your While loop from being so CPU intensive.
    2 points
  2. Use: If not (DriveGetFileSystem($DriveLetter) = 'abcd') Then Jos
    1 point
  3. I added the ASM Version which is 742 times faster on my notebook: #include <GDIPlus.au3> _GDIPlus_Startup() Global $bRawImage = Binary(FileRead("c:\Temp\myblob.raw")) ;adjust the path to the image! Global $e1, $e2, $t = TimerInit() Global $hBmp = _GDIPlus_BitmapCreateFromRawFormat($bRawImage, 1280, 1024) $e1 = TimerDiff($t) _GDIPlus_ImageRotateFlip($hBitmap, 2) ConsoleWrite("Runtime: " & Round($e1, 2) & " milli seconds." & @CRLF) _GDIPlus_ImageSaveToFile($hBmp, @ScriptDir & "\Converted1.png") $t = TimerInit() Global $hBmp2 = _GDIPlus_BitmapCreateFromRawFormat2($bRawImage, 1280, 1024) $e2 = TimerDiff($t) _GDIPlus_ImageRotateFlip($hBitmap, 2) ConsoleWrite("Runtime: " & Round($e2, 2) & " milli seconds." & @CRLF) ConsoleWrite("Factor: " & $e1 / $e2 & @CRLF) _GDIPlus_ImageSaveToFile($hBmp2, @ScriptDir & "\Converted2.png") _GDIPlus_BitmapDispose($hBmp) _GDIPlus_BitmapDispose($hBmp2) _GDIPlus_Shutdown() Func _GDIPlus_BitmapCreateFromRawFormat($bRaw, $iW, $iH, $iPixelFormat = $GDIP_PXF24RGB) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH, $iPixelFormat) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, $GDIP_ILMWRITE) Local $tPixel = DllStructCreate("int scan0[" & $iW * $iH & "];", $tBitmapData.Scan0) Local $i = 1, $iX, $iY Local $tBinaryArray = DllStructCreate("byte binary[" & BinaryLen($bRaw) & "]"), $iColor, $i $tBinaryArray.binary = $bRaw For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 $tPixel.scan0(($iRowOffset + $iX)) = $tBinaryArray.binary(($i)) + 0x100 * $tBinaryArray.binary(($i)) + 0x10000 * $tBinaryArray.binary(($i)) ;grayscale only / 8-bit $i += 1 Next Next _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) $tBinaryArray = 0 Return $hBitmap EndFunc Func _GDIPlus_BitmapCreateFromRawFormat2($bRaw, $iW, $iH, $iPixelFormat = $GDIP_PXF32RGB) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH, $iPixelFormat) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, $GDIP_ILMWRITE) Local $tPixel = DllStructCreate("int scan0[" & $iW * $iH & "];", $tBitmapData.Scan0) Local $i = 1, $iX, $iY Local $tPixelRaw = DllStructCreate("byte binary[" & BinaryLen($bRaw) & "]") $tPixelRaw.binary = $bRaw Local $tCodeBuffer = DllStructCreate("byte asm[41]") $tCodeBuffer.asm = "0x8B7424048B4C24088B54240C0FBE1A89D8C1E00801D8C1E00801D8890683C20183C60483E90177E4C3" DllCall("user32.dll", "ptr", "CallWindowProcW", "ptr", DllStructGetPtr($tCodeBuffer),"ptr", DllStructGetPtr($tPixel), "int", $iW * $iH, "ptr", DllStructGetPtr($tPixelRaw), "int", 0) _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) Return $hBitmap EndFunc #cs Func _CreateFromRaw() _("use32") ;32Bit! _("mov esi, dword[esp+4]") ;Startadress Bitmapdata (Pixel) -> scan0 _("mov ecx, dword[esp+8]") ;number of Pixel -> $iWidth * $iHeight _("mov edx, dword[esp+12]") ;Byte Array _("_loop1:") ;eax is a 32 bit value for the color of one pixel in ARGB format but the bitmap is initialized as 24 bit. Thus alpha channel is not needed and will be ignored _("movsx ebx, byte [edx]") ;copy the value from the raw image as a byte to ebx register _("mov eax, ebx") ;copy the 8-bit value from ebx to eax (red) _("shl eax, 8") ;shift the bits 8-bits to the left -> e.g. 0x0000AA -> 0x00AA00 (this is equal to a multiplication with 0x100) _("add eax, ebx") ;add the same byte again to eax -> 0x00AAAA (green) _("shl eax, 8") ;shift the bits again -> 0xAAAA00 _("add eax, ebx") ;add the same value last time to eax (blue) _("mov [esi], eax") ;write the pixel to the bitmap -> should be a greyscaled color value (0xAAAAAA) _("add edx, 1") ;get the next byte from the raw image byte array _("add esi, 4") ;address next pixel: 4 Byte = 1 dword = 1 Pixel _("sub ecx, 1") ;counter (next pixel) _("ja _loop1") _("ret ") ;return EndFunc ;==>_CreateFromRaw #ce PS: I'm learning ASM. Might be not the optimal ASM solution... Br, UEZ
    1 point
  4. caramen, how about you take your own advice? If a Mod deems it necessary to have a word with boththose, they will. It is not your place to pollute the thread. Reported the thread, specifically altered post #7. Let's let it rest until a Mod weighs in.
    1 point
  5. I'm not sure I fully understand your needs. But maybe this works: #include <array.au3> #include <StringConstants.au3> Global $sString = '\\BabyMAKER\root\CIMV2:Win32_Service.Name="Apache2.4"\\BabyMAKER\root\CIMV2:Win32_Service.Name="Apache2.4"\\BabyMAKER\root\CIMV2:Win32_Service.Name="AppIDSvc"\\BabyMAKER' $aResult = StringSplit($sString, "\\", $STR_ENTIRESPLIT) _ArrayDisplay($aResult)
    1 point
  6. Cynagen, Not entirely - my suggested solution also allows for other code to be run when the button is actioned. Whereas merely allowing the script to rename the button makes the whole thing a bit of a "self-licking lollipop". M23
    1 point
  7. NEW VERSION 11 Feb 15 Added: You can now select multiple items in the tree using checkboxes (just set the $iMultiple parameter to -1). Selecting or clearing an item with the Ctrl key pressed will check/clear all items lower in the tree as long as they have actually been expanded at least once - unexpanded items are unaffected as they do not exist in the dialog tree until they have been expanded. New: When using checkboxes items in the tree can be prechecked using the _CFF_SetPreCheck function. All items on the passed paths will be checked to give a visual indication that something is prechecked deeper within the tree. Prechecked items will always be returned unless the specific checkbox is expanded and cleared. There is an additional option for the $iDisplay parameter - adding 512 will only return the lowest item on any path so that checking higher level folders does not return them as well. It is not recommended to precheck significant numbers of items within the tree as checking newly expanded items against the large lists will increase the time taken for the tree to update. New zip in the first post. M23
    1 point
  8. Mugen

    Calling 7z.dll

    Well, didn't have much success. Seams the IArchiveExtractCallback object can be directly passed to the IInArchive Extract method . It will call IArchiveExtractCallback Addref and Release, but them end with error code 0x8007000E Working code to extract a 7z archive to a folder: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** ;~ #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinApi.au3> Global Const $sCLSID_Format7z = "{23170f69-40c1-278a-1000-000110070000}" ;=============================================================================== #interface "IInArchive" Global Const $sIID_IInArchive = "{23170F69-40C1-278A-0000-000600600000}" Global Const $tagIInArchive = _ "Open hresult(ptr;uint64*;ptr);" & _ "Close hresult();" & _ "GetNumberOfItems hresult(uint*);" & _ "GetProperty hresult(uint;uint;variant*);" & _ "Extract hresult(struct*;uint;int;ptr);" & _ "GetArchiveProperty hresult(int;variant*);" & _ "GetNumberOfProperties hresult(uint*);" & _ "GetPropertyInfo hresult(uint;bstr*;int*;int*);" & _ "GetNumberOfArchiveProperties hresult(uint*);" & _ "GetArchivePropertyInfo hresult(uint;bstr*;int*;int*);" ;=============================================================================== ;=============================================================================== #interface "ISequentialInStream" Global Const $sIID_ISequentialInStream = "{23170F69-40C1-278A-0000-000300010000}" Global Const $tagISequentialInStream = "Read hresult(ptr;uint;uint*);" ;=============================================================================== ;=============================================================================== #interface "IInStream" Global Const $sIID_IInStream = "{23170F69-40C1-278A-0000-000300030000}" Global Const $tagIInStream = _ $tagISequentialInStream & _ "Seek hresult(int64;uint;uint64*);" ;=============================================================================== ;=============================================================================== #interface "ISequentialStream" Global Const $sIID_ISequentialStream = "{0c733a30-2a1c-11ce-ade5-00aa0044773d}" Global Const $tagISequentialStream = _ "Read hresult(struct*;dword;ptr);" & _ "Write hresult(struct*;dword;dword*);" ;=============================================================================== ;=============================================================================== #interface "IStream" Global Const $sIID_IStream = "{0000000c-0000-0000-C000-000000000046}" Global Const $tagIStream = _ $tagISequentialStream & _ "Seek hresult(int64;dword;ptr);" & _ "SetSize hresult(uint64);" & _ "CopyTo hresult(ptr;uint64;uint64*;uint64*);" & _ "Commit hresult(dword);" & _ "Revert hresult();" & _ "LockRegion hresult(uint64;uint64;dword);" & _ "UnlockRegion hresult(uint64;uint64;dword);" & _ "Stat hresult(struct*;dword);" & _ "Clone hresult(ptr*);" ;=============================================================================== ;=============================================================================== #interface "IArchiveExtractCallback" Global Const $sIID_IArchiveExtractCallback = "{23170F69-40C1-278A-0000-000600200000}" Global Const $tagIArchiveExtractCallback = _ "SetTotal hresult(int);" & _ "SetCompleted hresult(int*);" & _ "GetStream hresult(int;ptr*;int*);" & _ "PrepareOperation hresult(int);" & _ "SetOperationResult hresult(int);" ;=============================================================================== ;=============================================================================== #interface "ISequentialOutStream" Global Const $sIID_ISequentialOutStream = "{23170F69-40C1-278A-0000-000300020000}" Global Const $tagISequentialOutStream = "Write hresult(ptr;uint;uint*);" ;=============================================================================== ;=============================================================================== #interface "IOutStream" Global Const $sIID_IOutStream = "{23170F69-40C1-278A-0000-000300040000}" Global Const $tagIOutStream = _ $tagISequentialOutStream & _ "Seek hresult(int64;dword;ptr);" & _ "SetSize hresult(uint64*)" ;=============================================================================== Global Const $sFilePath = @ScriptDir & "\lala.7z" Global Const $7zExtractDir = @ScriptDir & "\Extract\" Global Const $h7Z_DLL = DllOpen(@ProgramFilesDir & "\7-Zip\7z.dll") If $h7Z_DLL = -1 Then MsgBox(0, "error", "fehler beim laden der dll") Exit EndIf ; 1. Create IInArchive object: Local $oIInArchive = _7z_CreateObject($sCLSID_Format7z, $sIID_IInArchive, $tagIInArchive) ; 2. Create IStream on file: Local $oIStream = _WinAPI_SHCreateStreamOnFile($sFilePath) ; 2a. Create IInStream on file (wrapping IStream inside methods): Local $tIInStream Local $oIInStream = ObjectFromTag("IInStream_", $tagIInStream, $tIInStream, Default, $sIID_IInStream) ; 2b. Create IArchiveExtractCallback Object: Local $tIArchiveExtractCallback Local $oIArchiveExtractCallback = ObjectFromTag("IArchiveExtractCallback_", $tagIArchiveExtractCallback, $tIArchiveExtractCallback, Default, $sIID_IArchiveExtractCallback) ; 2c. Create IOutStream Object Local $oIStreamOut = CreateStreamOnHGlobal() ; in-memory here, you can use use file stream Local $tIOutStream Local $oIOutStream = ObjectFromTag("IOutStream_", $tagIOutStream, $tIOutStream, Default, $sIID_IOutStream) ; 3. Load the archive: $oIInArchive.Open($oIInStream, 1024, 0) ; 4. Do something with it. For example I will check how many compressed items are inside: Local $i $oIInArchive.GetNumberOfItems($i) ;~ MsgBox(0, "Number of items inside the archive", "i=" & $i & @CRLF) ; maybe to list what's inside Enum $kpidNoProperty = 0, $kpidMainSubfile = 1, $kpidHandlerItemIndex = 2, $kpidPath, $kpidName, $kpidExtension, $kpidIsDir, $kpidSize, $kpidPackSize ; etc... Global $7zFilesArray[$i] $tIndices = DllStructCreate("int[" & $i & "]") local $iExtractCount = $i For $j = 0 To $i - 1 Local $sName, $iSize, $iIsDir $oIInArchive.GetProperty($j, $kpidPath, $sName) $oIInArchive.GetProperty($j, $kpidSize, $iSize) $oIInArchive.GetProperty($j, $kpidIsDir, $iIsDir) $7zFilesArray[$j] = $sName ;Well it makes not much sense to extract a folder, so let's skip them IF Not $iIsDir Then DllStructSetData($tIndices, 1, $j, $j + 1) Else $iExtractCount -= 1 ;Maybe for empty folders DirCreate($7zExtractDir & $sName) Endif ;~ ConsoleWrite($j & @TAB & $sName & ", size = " & $iSize & " bytes" & @CRLF) Next $hresult = $oIInArchive.Extract($tIndices, $iExtractCount, 0, $oIArchiveExtractCallback) ConsoleWrite(@CRLF & "oIInArchive.Extract Return: " & Hex($hresult) & @crlf) ;<<<<<< The End >>>>>>>; ;======================; ; IInStream methods Func IInStream_QueryInterface($pSelf, $pRIID, $pObj) Local $tStruct = DllStructCreate("ptr", $pObj) ConsoleWrite("@IInStream_QueryInterface " & _WinAPI_StringFromGUID($pRIID) & @CRLF & @CRLF) Switch _WinAPI_StringFromGUID($pRIID) Case $sIID_IInStream Case Else ConsoleWrite("@IInStream_QueryInterface -> ERR" & @CRLF) Return $E_NOINTERFACE EndSwitch DllStructSetData($tStruct, 1, $pSelf) Return $S_OK EndFunc Func IInStream_AddRef($pSelf) Return 1 EndFunc Func IInStream_Release($pSelf) Return 0 EndFunc Func IInStream_Read($pSelf, $pData, $iSize, $iProcessedSize) Return $oIStream.Read($pData, $iSize, $iProcessedSize) EndFunc Func IInStream_Seek($pSelf, $iOffset, $iSeekOrigin, $iNewPosition) Return $oIStream.Seek($iOffset, $iSeekOrigin, $iNewPosition) EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; IOutStream methods Func IOutStream_QueryInterface($pSelf, $pRIID, $pObj) Local $tStruct = DllStructCreate("ptr", $pObj) ConsoleWrite("@IOutStream_QueryInterface " & _WinAPI_StringFromGUID($pRIID) & @CRLF & @CRLF) Switch _WinAPI_StringFromGUID($pRIID) Case $sIID_IOutStream Case Else ConsoleWrite("@IOutStream_QueryInterface -> ERR" & @CRLF) Return $E_NOINTERFACE EndSwitch DllStructSetData($tStruct, 1, $pSelf) Return $S_OK EndFunc Func IOutStream_AddRef($pSelf) Return 1 EndFunc Func IOutStream_Release($pSelf) Return 0 EndFunc Func IOutStream_Write($pSelf, $pData, $iSize, $iProcessedSize) ConsoleWrite("!!!IOutStream_Write" & @CRLF) Return $oIStreamOut.Write($pData, $iSize, $iProcessedSize) EndFunc Func IOutStream_Seek($pSelf, $iOffset, $iSeekOrigin, $iNewPosition) ConsoleWrite("!!!IOutStream_Seek" & @CRLF) Return $oIStreamOut.Seek($iOffset, $iSeekOrigin, $iNewPosition) EndFunc Func IOutStream_SetSize($pSelf, $iNewSize) Return $E_NOTIMPL EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; IArchiveExtractCallback methods Func IArchiveExtractCallback_QueryInterface($pSelf, $pRIID, $pObj) Local $tStruct = DllStructCreate("ptr", $pObj) ConsoleWrite("@IArchiveExtractCallback_QueryInterface " & _WinAPI_StringFromGUID($pRIID) & @CRLF & @CRLF) Switch _WinAPI_StringFromGUID($pRIID) Case $sIID_IArchiveExtractCallback Case Else ConsoleWrite("@IArchiveExtractCallback_QueryInterface -> ERR" & @CRLF) Return $E_NOINTERFACE EndSwitch DllStructSetData($tStruct, 1, $pSelf) Return $S_OK EndFunc Func IArchiveExtractCallback_AddRef($pSelf) ConsoleWrite("@IArchiveExtractCallback_AddRef" & @CRLF) Return 1 EndFunc Func IArchiveExtractCallback_Release($pSelf) ConsoleWrite("@IArchiveExtractCallback_Release" & @CRLF) Return 0 EndFunc Func IArchiveExtractCallback_SetTotal($pSelf, $total) ConsoleWrite("@IArchiveExtractCallback_SetTotal" & @CRLF) Return 0 EndFunc Func IArchiveExtractCallback_SetCompleted($pSelf, $completeValue) ConsoleWrite("@IArchiveExtractCallback_SetCompleted: " & $completeValue & @CRLF) Return $S_OK EndFunc Func IArchiveExtractCallback_GetStream($pSelf, $index, $outStream, $askExtractMode) ConsoleWrite("!@IArchiveExtractCallback_GetStream " & $index & " " & $7zExtractDir & $7zfilesArray[$index] & @CRLF) Local $tStruct = DllStructCreate("ptr", $outStream) Local $Stream = $oIOutStream(); DllStructSetData($tStruct, 1, $Stream) ;Free previous out stream IF $oIStreamOut Then $oIStreamOut.Release() Endif ;Make sure output file exist FileClose(FileOpen($7zExtractDir & $7zfilesArray[$index], 10)) ; Create IStream Interface from the new file $oIStreamOut = _WinAPI_SHCreateStreamOnFile($7zExtractDir & $7zfilesArray[$index]) Return $S_OK EndFunc Func IArchiveExtractCallback_PrepareOperation($pSelf, $askExtractMode) ConsoleWrite("@IArchiveExtractCallback_PrepareOperation" & @CRLF) ;~ IF $bCancel ;~ Return $E_ABORT ;~ endif Return $S_OK EndFunc Func IArchiveExtractCallback_SetOperationResult($pSelf, $resultEOperationResult) ConsoleWrite("@IArchiveExtractCallback_SetOperationResult" & @CRLF) Return $S_OK EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _7z_CreateObject($sCLSID, $sIID, $sTag) Local $tCLSID = _WinAPI_GUIDFromString($sCLSID) Local $tIID = _WinAPI_GUIDFromString($sIID) Local $aCall = DllCall($h7Z_DLL, "long", "CreateObject", "struct*", $tCLSID, "struct*", $tIID, "ptr*", 0) If @error Or $aCall[0] Then Return SetError(1, 0, 0) Return ObjCreateInterface($aCall[3], $sIID, $sTag) EndFunc Func _WinAPI_SHCreateStreamOnFile($sFile) Local $iGrfMode = 0x00000002 Local $aCall = DllCall("shlwapi.dll", "long", "SHCreateStreamOnFileW", "wstr", $sFile, "uint", $iGrfMode, "ptr*", 0) If @error Or $aCall[0] Then Return SetError(1, 0, 0) Return ObjCreateInterface($aCall[3], $sIID_IStream, $tagIStream) EndFunc Func ObjectFromTag($sFunctionPrefix, $tagInterface, ByRef $tInterface, $bIsUnknown = Default, $sIID = "{00000000-0000-0000-C000-000000000046}") ; last param is IID_IUnknown by default If $bIsUnknown = Default Then $bIsUnknown = True Local $sInterface = $tagInterface ; copy interface description Local $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _ "AddRef dword();" & _ "Release dword();" ; Adding IUnknown methods If $bIsUnknown Then $tagInterface = $tagIUnknown & $tagInterface ; Below line is really simple even though it looks super complex. It's just written weird to fit in one line, not to steal your attention Local $aMethods = StringSplit(StringTrimRight(StringReplace(StringRegExpReplace(StringRegExpReplace($tagInterface, "\w+\*", "ptr"), "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), @LF, 3) Local $iUbound = UBound($aMethods) Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams, $hCallback ; Allocation $tInterface = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[" & $iUbound & "];int_ptr Callbacks[" & $iUbound & "];ulong_ptr Slots[16]") ; 16 pointer sized elements more to create space for possible private props If @error Then Return SetError(1, 0, 0) For $i = 0 To $iUbound - 1 $aSplit = StringSplit($aMethods[$i], "|", 2) If UBound($aSplit) <> 2 Then ReDim $aSplit[2] $sNamePart = $aSplit[0] ; Replace COM types by matching dllcallback types $sTagPart = StringReplace(StringReplace(StringReplace(StringReplace($aSplit[1], "object", "idispatch"), "hresult", "long"), "bstr", "ptr"), "variant", "ptr") $sMethod = $sFunctionPrefix & $sNamePart $aTagPart = StringSplit($sTagPart, ";", 2) $sRet = $aTagPart[0] $sParams = StringReplace($sTagPart, $sRet, "", 1) $sParams = "ptr" & $sParams $hCallback = DllCallbackRegister($sMethod, $sRet, $sParams) DllStructSetData($tInterface, "Methods", DllCallbackGetPtr($hCallback), $i + 1) ; save callback pointer DllStructSetData($tInterface, "Callbacks", $hCallback, $i + 1) ; save callback handle Next DllStructSetData($tInterface, "RefCount", 1) ; initial ref count is 1 DllStructSetData($tInterface, "Size", $iUbound) ; number of interface methods DllStructSetData($tInterface, "Object", DllStructGetPtr($tInterface, "Methods")) ; Interface method pointers Return ObjCreateInterface(DllStructGetPtr($tInterface, "Object"), $sIID, $sInterface, $bIsUnknown) ; pointer that's wrapped into object EndFunc Func DeleteObjectFromTag(ByRef $tInterface) For $i = 1 To DllStructGetData($tInterface, "Size") DllCallbackFree(DllStructGetData($tInterface, "Callbacks", $i)) Next $tInterface = 0 EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func ReadBinaryFromStream($oStream, $iWantedSize = Default) Local Const $S_OK = 0, $S_FALSE = 1 Local Enum $STREAM_SEEK_SET = 0, $STREAM_SEEK_CUR, $STREAM_SEEK_END ; Set stream position to the start in case it wouldn't be $oStream.Seek(0, $STREAM_SEEK_SET, 0) ; Determine the size of the stream Local $tSize = DllStructCreate("uint64") $oStream.Seek(0, $STREAM_SEEK_END, DllStructGetPtr($tSize)) Local $iSize = DllStructGetData($tSize, 1) If $iSize = 0 Then ; empty Return SetError(2, 0, 0) EndIf ; Back to start for reading correctly $oStream.Seek(0, $STREAM_SEEK_SET, 0) ; Make structure in size of binary data If $iSize = -1 Then $iSize = 262144 ; IStream my not be fair and return the size. In that case I'll use some reasonably sized buffer and read in loop. If ($iWantedSize <> Default) And ($iWantedSize < $iSize) Then $iSize = $iWantedSize Local $tBinary = DllStructCreate("byte[" & $iSize & "]") ; Read to it Local $tRead = DllStructCreate("dword") Local $bBinary = Binary(""), $iOverallRead While 1 Switch $oStream.Read($tBinary, $iSize, DllStructGetPtr($tRead)) Case $S_OK $iOverallRead += DllStructGetData($tRead, 1) $bBinary &= DllStructGetData($tBinary, 1) Case $S_FALSE $iOverallRead += DllStructGetData($tRead, 1) $bBinary &= BinaryMid(DllStructGetData($tBinary, 1), 1, DllStructGetData($tRead, 1)) ExitLoop Case Else ExitLoop EndSwitch If $iOverallRead <= $iSize Then ExitLoop WEnd ; Return binary data Return SetExtended($iOverallRead, $bBinary) EndFunc Func CreateStreamOnHGlobal($hGlobal = 0, $iFlag = 1) Local $aCall = DllCall("ole32.dll", "long", "CreateStreamOnHGlobal", "handle", $hGlobal, "int", $iFlag, "ptr*", 0) If @error Or $aCall[0] Then Return SetError(1, 0, 0) Return ObjCreateInterface($aCall[3], $sIID_IStream, $tagIStream) EndFunc
    1 point
  9. Today is the final day for entries. Please make sure you get them to jaberwacky before midnight local time. People living on Howland Island get an extra four hours because of the International Date Line. Thanks for the entries received so far, although I haven't seen any of them yet. Also thanks to everyone involved.
    1 point
×
×
  • Create New...