#include <file.au3>
#include <Array.au3>
#Include <Security.au3>
Global $cUsrFile = "D:\tst.cmpnd"
If Not _isOleFile($cUsrFile1c) Then
MsgBox(16, '<Error!>', $cUsrFile1c & " == НЕ iStorage-файл!");
Exit -1
EndIf
MsgBox(64, '<Ok>', $cUsrFile1c & " == iStorage-файл...");
Local $tStg = DllStructCreate('int')
Local $pStg = DllStructGetPtr($tStg)
Global $aStgOpened = DllCall("Ole32.dll", 'int', 'StgOpenStorage', _
'wstr', $cUsrFile1c, 'ptr', 0, 'int', BitOR(0x00400000, 0, 0x00000040), 'ptr', 0, 'int', 0, 'ptr', $pStg )
_ArrayDisplay( $aStgOpened, '<StgOpenStorage>')
Global $pStream=0
Global $aRetStreamOpen = DllCall("Ole32.dll", 'int', 'OpenStream', _
"wstr", "Container.Contents", "ptr", 0, "int", 16, "int", 0, "ptr", $pStream );
If IsArray($aRetStreamOpen) Then
MsgBox (64, "<OpenStream>", "Array = " & UBound($aRetStreamOpen) ; ТУТ: "Array = 0"
_ArrayDisplay( $aRetStreamOpen, '<OpenStream>')
Else
MsgBox (16, "<OpenStream>", "Array = " & UBound($aRetStreamOpen) )
EndIf
Да, спасибо, но перекопано по таким ссылкам все...inververs сказал(а):... Вот тут ...
Global Const $S_OK = 0
Local $sFileName = @ScriptDir & '\1.xls'
If Not _Ole32_StgIsStorageFile($sFileName) Then
Exit MsgBox(0, '', 'Не StgIsStorageFile')
EndIf
Local $iMode = BitOR(0x00400000, 0, 0x00000040);
Local $aRet = DllCall("Ole32.dll", 'LONG', 'StgOpenStorage', 'wstr', $sFileName, 'ptr', 0, 'int', $iMode, 'ptr', 0, 'int', 0, 'ptr*', 0)
If @error Or Not IsArray($aRet) Then
Exit MsgBox(0, '', 'DllCall ошибка ' & @error)
EndIf
If Not $aRet[0] = $S_OK Then
Exit MsgBox(0, '', 'Результат не $S_OK ' & Hex($aRet[0]))
EndIf
Local $pIStorage = $aRet[6]
MsgBox(0, '', 'Указатель на IStorage ' & $pIStorage)
;~ ... и т.д.
Func _Ole32_StgIsStorageFile($sFileName)
Local $aRet = DllCall("Ole32.dll", 'int', 'StgIsStorageFile', 'wstr', $sFileName)
If $aRet[0] = $S_OK Then
Return True
Else
Return False
EndIf
EndFunc
If StringLeft(_ArrayToString(DllCall("Ole32.dll", 'int', 'StgIsStorageFile', 'wstr', $cUsrFile1c), "#"),2) <> "0#" Then Exit MsgBox(16, '<Error!>', $cUsrFile1c & " == if NOT iStorage-file !");
MsgBox(64, '<Ok>', $cUsrFile1c & " is iStorage-file ...");
Local $iMode = BitOR(0x00400000, 0, 0x00000040);
Local $cMsg=""
Local $aStgOpened = DllCall("Ole32.dll", 'LONG', 'StgOpenStorage', 'wstr', $cUsrFile1c, 'ptr', 0, 'int', $iMode, 'ptr', 0, 'int', 0, 'ptr*', 0)
If @error Or Not IsArray($aStgOpened) Then Exit MsgBox(16, 'debug: <StgOpenStorage>', 'DllCall ошибка ' & @error)
If Not $aStgOpened[0] = $S_OK Then Exit MsgBox(16, 'debug: <StgOpenStorage>', 'Результат не $S_OK ' & Hex($aStgOpened[0]))
Local $pIStorage = $aStgOpened[6]
MsgBox(64, 'debug: <StgOpenStorage>', 'Указатель на IStorage ' & $pIStorage)
If Not IsArray($aStgOpened) Then Exit MsgBox (16, "debug: <StgOpenStorage>", $cMsg & @CRLF & "(ERROR) Return(" & VarGetType($aStgOpened) & ") = " & $aStgOpened )
$cMsg &= @CRLF & "Return Array = " & UBound($aStgOpened)
If UBound($aStgOpened) = 0 Then Exir MsgBox (16, "debug: <StgOpenStorage ERROR>", $cMsg)
MsgBox (64, "debug: <StgOpenStorage>", $cMsg & " " & $aStgOpened[0])
_ArrayDisplay( $aStgOpened, 'debug: <StgOpenStorage>')
$cMsg = ""
Local $cStreamName = "Container.Contents" & ChrW(0x0000)
Local $aStreamOpened = DllCall("Ole32.dll", 'LONG', 'OpenStream', 'wstr', $cStreamName, 'ptr', 0, 'int', $iMode, 'ptr', 0, 'ptr*', 0)
If @error Or Not IsArray($StreamOpened) Then Exit MsgBox(16, 'debug: <OpenStream>', 'DllCall ошибка ' & @error) ; ТУТ: DllCall ошибка 3
inververs сказал(а):Все правильно, в Ole32.dll нету функции OpenStream
ну или если врут - то как надо?... DLL: Ole32.dll ...
А дальше мы вступаем на скользкую дорожку работы с объектами, причем не унаследованных от IDispatch и начинаем активно использовать функциюну или если врут - то как надо?
ObjCreateInterface