Jump to content

Calling 7z.dll


Starg
 Share

Recommended Posts

I think your parameter type definition separators in method description strings should be ";" (and not ",").

Link to comment
Share on other sites

Thank you LarsJ,

you are right, these ',' are wrong. This also fixes the problems I got. So then, I can go deeper now with 7zip... when there are some functions ready, I will post them ;)

Link to comment
Share on other sites

When working with stream object you don't need file functions.

Check the errors you get, methods for objects created with ObjectFromTag allways have $pSelf as first parameter in definitions. Yours don't, hence the errors.

 

edit:

Here (just changed your code a bit, paths also to work for me):

#include <WinApi.au3>

Global Const $sCLSID_Format7z = "{23170f69-40c1-278a-1000-000110070000}"

;===============================================================================
#interface "IInArchive"
Global Const $sIID_IInArchive = "{23170F69-40C1-278A-0000-000600600000}" ; IUnknown
Global Const $tagIInArchive = _
        "Open hresult(ptr;uint64*;ptr);" & _                     ; STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback) x; \
        "Close hresult();" & _                                   ; STDMETHOD(Close)() x; \
        "GetNumberOfItems hresult(uint*);" & _                   ; STDMETHOD(GetNumberOfItems)(UInt32 *numItems) x; \
        "GetProperty hresult(uint;uint;variant*);" & _            ; STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) x; \
        "Extract hresult(uint;uint;int;ptr);" & _                ; STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) x; \
        "GetArchiveProperty hresult(int;variant*);" & _          ; STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) x; \
        "GetNumberOfProperties hresult(uint*);" & _              ; STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
        "GetPropertyInfo hresult(uint;bstr*;int*;int*);" & _     ; STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
        "GetNumberOfArchiveProperties hresult(uint*);" & _       ; STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) x; \
        "GetArchivePropertyInfo hresult(uint;bstr*;int*;int*);" ; STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x;
;===============================================================================


;===============================================================================
#interface "ISequentialInStream"
Global Const $sIID_ISequentialInStream = "{23170F69-40C1-278A-0000-000300010000}" ; IUnknown
Global Const $tagISequentialInStream = "Read hresult(ptr;uint;uint*);"
;===============================================================================

;===============================================================================
#interface "IInStream"
Global Const $sIID_IInStream = "{23170F69-40C1-278A-0000-000300030000}" ; ISequentialInStream
Global Const $tagIInStream = _
        $tagISequentialInStream & _
        "Seek hresult(int64;uint;uint64*);"
;===============================================================================


;===============================================================================
#interface "ISequentialStream"
Global Const $sIID_ISequentialStream = "{0c733a30-2a1c-11ce-ade5-00aa0044773d}" ; IUnknown
Global Const $tagISequentialStream = _
        "Read hresult(struct*;dword;ptr);" & _
        "Write hresult(struct*;dword;dword*);"
;===============================================================================

;===============================================================================
#interface "IStream"
Global Const $sIID_IStream = "{0000000c-0000-0000-C000-000000000046}" ; ISequentialStream
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*);"
;===============================================================================

Global Const $sFilePath = @ScriptDir & "\lala.7z"
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)

; 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...

For $j = 0 To $i - 1
    Local $sName, $iSize
    $oIInArchive.GetProperty($j, $kpidPath, $sName)
    $oIInArchive.GetProperty($j, $kpidSize, $iSize)
    ConsoleWrite($sName & ", size = " & $iSize & " bytes" & @CRLF)
Next


;<<<<<< 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






;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

...Look only if you are desperate.

It's really simple. Maybe. Sanity checking is missing.

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • 2 months later...

hey trancexx, i am currently working on this project for the moment, and I am able to get most things going but when it comes to getting a file to extract im at a loss.

The last bit im attempting to pull off is to extract a file, and/or extract it directly to memory.

here is what i have so far...

#include <WinApi.au3>
#Include <7zConst.au3>
#Include <Array.au3>
#Include-Once

;Global Const $sFilePath=
;Implement MemoryMode
Global $_h7z_Dll
Global $_o7z_IInArchive,$_o7z_IStream,$_t7z_IInStream,$_o7z_IInStream

_7zInit()
_7zOpen(@ScriptDir&"\Test.7z")
;_7zSearch(".inf")
_7zGetPaths()
_7zExtract("matchver\FORCED\5x86\D-Link\DGE-660\DGE660T.INF")
_7zClose()
;_7zUnInit()

Func _7zGetPaths()
    Local $aList=_7zListToArray()
    Local $sResults
    Local $aResults[0][2]
    Local $iBounds=UBound($aList,1)-1
    For $iIndex=0 To $iBounds
        $bTest=$aList[$iIndex][1]="True"
        If $bTest Then
            $sResults&=$iIndex&"|"&$aList[$iIndex][0]&@CRLF
        EndIf
    Next
    If StringRight($sResults,2)=@CRLF Then $sResults=StringTrimRight($sResults,2)
    __ArrayAdd($aResults,$sResults)
    Return $aResults
EndFunc

;"Extract hresult(uint;uint;int;ptr)

; STDMETHOD(Extract)(const UInt32* indices,UInt32 numItems,Int32 testMode,IArchiveExtractCallback *extractCallback) x; \

Func _7zExtract($vFilePath)
    Local $bIsPath,$bIsMulti
    If IsArray($vFilePath) Then
        ;HandelArray
        Return 1
    EndIf
    If IsString($vFilePath) Then
        Local $aList=_7zListToArray()
        $_i7z_FileIndex=_ArraySearch($aList,$vFilePath)
        Local $hCallback
        ConsoleWrite($_o7z_IInArchive.Extract($_i7z_FileIndex,1,0,$hCallback)&@CRLF)
        ConsoleWrite(VarGetType($hCallback)&"|"&$hCallback&"|"&Binary($hCallback)&@CRLF)
    EndIf
EndFunc

Func _7zFileExtractMem()
;$_o7z_IStream= _WinAPI_SHCreateStreamOnFile($sFilePath)
EndFunc

Func _7zSearch($sQuery)
    Local $aList=_7zListToArray()
    Local $sResults
    Local $aResults[0][2]
    $aSearch=_ArrayFindAll($aList,$sQuery,0,0,0,1,0)
    $iBounds=UBound($aSearch,1)-1
    For $iIndex=1 To $iBounds
        If $iIndex=$iBounds Then
            $sResults&=$aSearch[$iIndex]&"|"&$aList[$aSearch[$iIndex]][0]
        Else
            $sResults&=$aSearch[$iIndex]&"|"&$aList[$aSearch[$iIndex]][0]&@CRLF
        EndIf
    Next
    __ArrayAdd($aResults,$sResults)
    Return $aResults
EndFunc

Func _7zInit()
    If $_h7z_Dll="" Then
        $_h7z_Dll=DllOpen(@ScriptDir&"\7z.dll")
        If $_h7z_Dll=-1 Then
            Return 1
        EndIf
    EndIf
    ; 1. Create IInArchive object:
    $_o7z_IInArchive= _7z_CreateObject($_s7z_CLSID_Format7z,$_s7z_IID_IInArchive,$_tag7z_IInArchive)
    If Not IsObj($_o7z_IInArchive) Then
        $_o7z_IInArchive=""
    EndIf
EndFunc

Func _7zOpen($sFilePath)
    ; 2. Create IStream on file:
    $_o7z_IStream= _WinAPI_SHCreateStreamOnFile($sFilePath)
    If Not IsObj($_o7z_IInArchive) Then Exit 2
    ; 2a. Create IInStream on file (wrapping IStream inside methods):
    $_t7z_IInStream=""
    $_o7z_IInStream=ObjectFromTag("IInStream_",$_tag7z_IInStream,$_t7z_IInStream,Default,$_s7z_IID_IInStream)
    If Not IsObj($_o7z_IInArchive) Then Exit 6
    ; 3. Load the archive:
    $_o7z_IInArchive.Open($_o7z_IInStream,1024,0)
    ;Return $_o7z_IInStream
EndFunc


Func _7zClose()
    $_o7z_IInArchive.Close()
EndFunc

Func _7zGetItemCount()
    ; 4. Do something with it. For example I will check how many compressed items are inside:
    Local $iCount
    $_o7z_IInArchive.GetNumberOfItems($iCount)
    Return $iCount
EndFunc

Func _7zGetPropertyCount()
    Local $iCount
    $_o7z_IInArchive.GetNumberOfArchiveProperties($iCount)
    Return $iCount
EndFunc

Func _7zListToArray()
    $iMaxCount=_7zGetItemCount()
    Local $iTempNumOfProperties
    Local $vResult
    Local $vResults=""
    Local $aResults[0][4]
    For $b=0 To $iMaxCount-1
        $vResult=""
        $iMaxProps=UBound($_a7z_PropID,1)-1
        $vResult=""
        $_o7z_IInArchive.GetProperty($b,3,$vResult)
        $vResults&=$vResult&"|"
        $vResult=""
        $_o7z_IInArchive.GetProperty($b,6,$vResult)
        $vResults&=$vResult&"|"
        $vResult=""
        $_o7z_IInArchive.GetProperty($b,7,$vResult)
        $vResults&=$vResult&"|"
        $vResult=""
        $_o7z_IInArchive.GetProperty($b,8,$vResult)
        If $b=$iMaxCount-1 Then
            $vResults&=$vResult
        Else
            $vResults&=$vResult&@CRLF
        EndIf
        ;onsoleWrite($vResult&@CRLF)
        ;_ArrayDisplay($aResults)
    Next
    __ArrayAdd($aResults,$vResults)
    Return $aResults
EndFunc

;<<<<<< The End >>>>>>>;
;======================;

Func __ArrayAdd(ByRef $avArray,$vValue,$iStart=0,$sDelim_Item="|",$sDelim_Row=@CRLF,$hDataType=0)
    If $iStart=Default Then $iStart=0
    If $sDelim_Item=Default Then $sDelim_Item="|"
    If $sDelim_Row=Default Then $sDelim_Row=@CRLF
    If $hDataType=Default Then $hDataType=0
    If Not IsArray($avArray) Then Return SetError(1,0,-1)
    Local $iDim_1=UBound($avArray,$UBOUND_ROWS)
    Switch UBound($avArray,$UBOUND_DIMENSIONS)
        Case 1
            If IsArray($vValue) Then
                If UBound($vValue,$UBOUND_DIMENSIONS)<>1 Then Return SetError(5,0,-1)
                $hDataType=0
            Else
                Local $aTmp=StringSplit($vValue,$sDelim_Item,$STR_NOCOUNT+$STR_ENTIRESPLIT)
                If UBound($aTmp,$UBOUND_ROWS)=1 Then
                    $aTmp[0]=$vValue
                    $hDataType=0
                EndIf
                $vValue=$aTmp
            EndIf
            Local $iAdd=UBound($vValue,$UBOUND_ROWS)
            ReDim $avArray[$iDim_1+$iAdd]
            For $i=0 To $iAdd-1
                If IsFunc($hDataType) Then
                    $avArray[$iDim_1+$i]=$hDataType($vValue[$i])
                Else
                    $avArray[$iDim_1+$i]=$vValue[$i]
                EndIf
            Next
            Return $iDim_1+$iAdd-1
        Case 2
            Local $iDim_2=UBound($avArray,$UBOUND_COLUMNS)
            If $iStart<0 Or $iStart>$iDim_2-1 Then Return SetError(4,0,-1)
            Local $iValDim_1,$iValDim_2
            If IsArray($vValue) Then
                If UBound($vValue,$UBOUND_DIMENSIONS)<>2 Then Return SetError(5,0,-1)
                $iValDim_1=UBound($vValue,$UBOUND_ROWS)
                $iValDim_2=UBound($vValue,$UBOUND_COLUMNS)
                $hDataType=0
            Else
                ; Convert string to 2D array
                Local $aSplit_1=StringSplit($vValue,$sDelim_Row,$STR_NOCOUNT+$STR_ENTIRESPLIT)
                $iValDim_1=UBound($aSplit_1,$UBOUND_ROWS)
                StringReplace($aSplit_1[0],$sDelim_Item,"")
                $iValDim_2=@extended+1
                Local $aTmp[$iValDim_1][$iValDim_2],$aSplit_2
                For $i=0 To $iValDim_1-1
                    $aSplit_2=StringSplit($aSplit_1[$i],$sDelim_Item,$STR_NOCOUNT+$STR_ENTIRESPLIT)
                    ;_ArrayDisplay($aSplit_2)
                    If UBound($aSplit_2,1)=1 Then ContinueLoop
                    For $j=0 To $iValDim_2-1
                        $aTmp[$i][$j]=$aSplit_2[$j]
                    Next
                Next
                $vValue=$aTmp
            EndIf
            ; Check if too many columns to fit
            If UBound($vValue,$UBOUND_COLUMNS)+$iStart>UBound($avArray,$UBOUND_COLUMNS) Then Return SetError(3,0,-1)
            ReDim $avArray[$iDim_1+$iValDim_1][$iDim_2]
            For $iWriteTo_Index=0 To $iValDim_1-1
                For $j=0 To $iDim_2-1
                    If $j<$iStart Then
                        $avArray[$iWriteTo_Index+$iDim_1][$j]=""
                    ElseIf $j-$iStart>$iValDim_2-1 Then
                        $avArray[$iWriteTo_Index+$iDim_1][$j]=""
                    Else
                        If IsFunc($hDataType) Then
                            $avArray[$iWriteTo_Index+$iDim_1][$j]=$hDataType($vValue[$iWriteTo_Index][$j-$iStart])
                        Else
                            $avArray[$iWriteTo_Index+$iDim_1][$j]=$vValue[$iWriteTo_Index][$j-$iStart]
                        EndIf
                    EndIf
                Next
            Next
        Case Else
            Return SetError(2,0,-1)
    EndSwitch
    Return UBound($avArray,$UBOUND_ROWS)-1
EndFunc   ;==>_ArrayAdd


; 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 $_s7z_IID_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 $_o7z_IStream.Read($pData,$iSize,$iProcessedSize)
EndFunc

Func IInStream_Seek($pSelf,$iOffset,$iSeekOrigin,$iNewPosition)
    Return $_o7z_IStream.Seek($iOffset,$iSeekOrigin,$iNewPosition)
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],$_s7z_IID_IStream,$_tag7z_IStream)
EndFunc

Func ObjectFromTag($sFunctionPrefix,$_tag7z_Interface, 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=$_tag7z_Interface ; copy interface description
    Local $_tag7z_IUnknown="QueryInterface hresult(ptr;ptr*);"& _
            "AddRef dword();"& _
            "Release dword();"
    ; Adding IUnknown methods
    If $bIsUnknown Then $_tag7z_Interface=$_tag7z_IUnknown&$_tag7z_Interface
    ; 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($_tag7z_Interface,"\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

7zConst.au3

#Include-Once
Global Const $_s7z_CLSID_Format7z="{23170f69-40c1-278a-1000-000110070000}"

;===============================================================================
#interface "IInArchive"
Global Const $_s7z_IID_IInArchive="{23170F69-40C1-278A-0000-000600600000}";IUnknown
Global Const $_tag7z_IInArchive= _
        "Open hresult(ptr;uint64*;ptr);"& _                     ; STDMETHOD(Open)(IInStream *stream,const UInt64 *maxCheckStartPosition,IArchiveOpenCallback *openArchiveCallback) x; \
        "Close hresult();"& _                                   ; STDMETHOD(Close)() x; \
        "GetNumberOfItems hresult(uint*);"& _                   ; STDMETHOD(GetNumberOfItems)(UInt32 *numItems) x; \
        "GetProperty hresult(uint;uint;variant*);"& _            ; STDMETHOD(GetProperty)(UInt32 index,PROPID propID,PROPVARIANT *value) x; \
        "Extract hresult(uint;uint;int;ptr);"& _                ; STDMETHOD(Extract)(const UInt32* indices,UInt32 numItems,Int32 testMode,IArchiveExtractCallback *extractCallback) x; \
        "GetArchiveProperty hresult(int;variant*);"& _          ; STDMETHOD(GetArchiveProperty)(PROPID propID,PROPVARIANT *value) x; \
        "GetNumberOfProperties hresult(uint*);"& _              ; STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
        "GetPropertyInfo hresult(uint;bstr*;int*;int*);"& _     ; STDMETHOD(GetPropertyInfo)(UInt32 index,BSTR *name,PROPID *propID,VARTYPE *varType) x; \
        "GetNumberOfArchiveProperties hresult(uint*);"& _       ; STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) x; \
        "GetArchivePropertyInfo hresult(uint;bstr*;int*;int*);" ; STDMETHOD(GetArchivePropertyInfo)(UInt32 index,BSTR *name,PROPID *propID,VARTYPE *varType) x;
;===============================================================================


;===============================================================================
#interface "ISequentialInStream"
Global Const $_s7z_IID_ISequentialInStream="{23170F69-40C1-278A-0000-000300010000}" ; IUnknown
Global Const $_tag7z_ISequentialInStream="Read hresult(ptr;uint;uint*);"
;===============================================================================

;===============================================================================
#interface "IInStream"
Global Const $_s7z_IID_IInStream="{23170F69-40C1-278A-0000-000300030000}" ; ISequentialInStream
Global Const $_tag7z_IInStream= _
        $_tag7z_ISequentialInStream& _
        "Seek hresult(int64;uint;uint64*);"
;===============================================================================


;===============================================================================
#interface "ISequentialStream"
Global Const $_s7z_IID_ISequentialStream="{0c733a30-2a1c-11ce-ade5-00aa0044773d}" ; IUnknown
Global Const $_tag7z_ISequentialStream= _
        "Read hresult(struct*;dword;ptr);"& _
        "Write hresult(struct*;dword;dword*);"
;===============================================================================

;===============================================================================
#interface "IStream"
Global Const $_s7z_IID_IStream="{0000000c-0000-0000-C000-000000000046}" ; ISequentialStream
Global Const $_tag7z_IStream= _
        $_tag7z_ISequentialStream& _
        "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*);"
;===============================================================================

;Global 7zProps
Global $_a7z_PropID[63]
$_a7z_PropID[0]="kpidNoProperty"
$_a7z_PropID[1]="kpidMainSubfile";=1
$_a7z_PropID[2]="kpidHandlerItemIndex";=2
$_a7z_PropID[3]="kpidPath"
$_a7z_PropID[4]="kpidName"
$_a7z_PropID[5]="kpidExtension"
$_a7z_PropID[6]="kpidIsDir"
$_a7z_PropID[7]="kpidSize"
$_a7z_PropID[8]="kpidPackSize"
$_a7z_PropID[9]="kpidAttrib"
$_a7z_PropID[10]="kpidCTime"
$_a7z_PropID[11]="kpidATime"
$_a7z_PropID[12]="kpidMTime"
$_a7z_PropID[13]="kpidSolid"
$_a7z_PropID[14]="kpidCommented"
$_a7z_PropID[15]="kpidEncrypted"
$_a7z_PropID[16]="kpidSplitBefore"
$_a7z_PropID[17]="kpidSplitAfter"
$_a7z_PropID[18]="kpidDictionarySize"
$_a7z_PropID[19]="kpidCRC"
$_a7z_PropID[20]="kpidType"
$_a7z_PropID[21]="kpidIsAnti"
$_a7z_PropID[22]="kpidMethod"
$_a7z_PropID[23]="kpidHostOS"
$_a7z_PropID[24]="kpidFileSystem"
$_a7z_PropID[25]="kpidUser"
$_a7z_PropID[26]="kpidGroup"
$_a7z_PropID[27]="kpidBlock"
$_a7z_PropID[28]="kpidComment"
$_a7z_PropID[29]="kpidPosition"
$_a7z_PropID[30]="kpidPrefix"
$_a7z_PropID[31]="kpidNumSubDirs"
$_a7z_PropID[32]="kpidNumSubFiles"
$_a7z_PropID[33]="kpidUnpackVer"
$_a7z_PropID[34]="kpidVolume"
$_a7z_PropID[35]="kpidIsVolume"
$_a7z_PropID[36]="kpidOffset"
$_a7z_PropID[37]="kpidLinks"
$_a7z_PropID[38]="kpidNumBlocks"
$_a7z_PropID[39]="kpidNumVolumes"
$_a7z_PropID[40]="kpidTimeType"
$_a7z_PropID[41]="kpidBit64"
$_a7z_PropID[42]="kpidBigEndian"
$_a7z_PropID[43]="kpidCpu"
$_a7z_PropID[44]="kpidPhySize"
$_a7z_PropID[45]="kpidHeadersSize"
$_a7z_PropID[46]="kpidChecksum"
$_a7z_PropID[47]="kpidCharacts"
$_a7z_PropID[48]="kpidVa"
$_a7z_PropID[49]="kpidId"
$_a7z_PropID[50]="kpidShortName"
$_a7z_PropID[51]="kpidCreatorApp"
$_a7z_PropID[52]="kpidSectorSize"
$_a7z_PropID[53]="kpidPosixAttrib"
$_a7z_PropID[54]="kpidLink"
$_a7z_PropID[55]="kpidError"
$_i7z_kpidTotalSize=0x1100;$_a7z_PropID[56]="kpidTotalSize = 0x1100"
$_a7z_PropID[57]="kpidFreeSpace"
$_a7z_PropID[58]="kpidClusterSize"
$_a7z_PropID[59]="kpidVolumeName"
$_i7z_kpidLocalName=0x1200;$_a7z_PropID[60]="kpidLocalName"; = 0x1200"
$_a7z_PropID[61]="kpidProvider"
$_i7z_kpidUserDefined=0x10000;$_a7z_PropID[62]="kpidUserDefined"; = 0x10000'
;ConsoleWrite(UBound($_a7z_PropID,1)-1)

Edit: Added Include

Edited by Biatu

What is what? What is what.

Link to comment
Share on other sites

  • 6 months later...

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
Edited by Mugen
Link to comment
Share on other sites

I have archived 3 RTF files.
The archive is stored in the database as a BLOB.
After reading the data from the database, but without saving them to disk, How to read the content of these 3 RTF ?.
 
Is the functions discussed here allow to make such a task ?
Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Hi mLipok,
 
that should be no problem, the 7z interface doesn't want files it want streams.
 
You could try it as following:
 
1. create your $oIStream using CreateStreamOnHGlobal() and fill it with the buffer you have extracted
2. the same way create outstreams for the files you want to extract
3. In function IArchiveExtractCallback_GetStream you pass these outstream to the callback
4. after extract function finished, use the ReadBinaryFromStream() function to convert stream to a buffer
Link to comment
Share on other sites

Thanks for answer.
 
Is this the way I handle different types or just 7z archive.
Would need to zip and unzip support, and unrar.
 
Excuse me for asking, and do not check myself.
I first need to know at a glance if it was possible to go into the details of the documentation.
Even so, the plan is very distant in time, because now I realize other tasks.
 
mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Awesome.

The last question.

Can this function and 7zip be used in commercial product with closed source ?

Regardless of the answer to my last question, I have to deeper interest in the subject.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Awesome.

The last question.

Can this function and 7zip be used in commercial product with closed source ?

Regardless of the answer to my last question, I have to deeper interest in the subject.

If I'm right this is the License for use and distribution

Saludos

Link to comment
Share on other sites

Thanks.

mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • 2 weeks later...

I would be very grateful if someone developed a UDF for 7z.dll operating on binary data instead of files, of course, for different types of archives.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

+1 from me! An UDF would be awesome, but who's crazy enough to do that.

I mean just look how well 7z interface is "documented"

 

Another idea for disk-less usage, before i forget it again  :sweating:

1. Writing the memory 7z file into a pipe, so we can use 7z.exe on it without saving to disc.

2. Running 7z with stdout option

3. We know the Indices order and files sizes thanks to the code from trancexx in post >#23,

    so it should be able to parse this output.

Edited by Mugen
Link to comment
Share on other sites

If you want to compress any binary data from memory why is LZMA from here '?do=embed' frameborder='0' data-embedContent>> not an option?

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

+1 from me! An UDF would be awesome, but who's crazy enough to do that.

I mean just look how well 7z interface is "documented"

I agree the documentation to 7z is poor or just "not discovered yet"  :)

mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • 3 weeks later...

@UEZ, yes the LZMA machine code is great for simple things. But I can't be used for complete archives.

 

Hello again,

 

the way, the 7z.dll wants to be used is a bit strange, so I decided to give up trying to create some nice UDF for it.

 

But I  found a much nicer way for using 7-Zip and it's great features for generating and updating archives. I re-used the source of 7zg.exe and created a new 7zg-mini.exe, you can find the documentation and the code here: http://mcmilk.de/projects/USB-Backup/   - search for 7zg-mini

It is a bit more code then normal, so I will not Post it here ;)

And the USB-Backup there is an "AutoIt application" ... full source of it is also there... but most comments are in german, sorry.

 

with best regards,

Tino

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...