Пытаюсь реализовать сабж, но даже после трёхдневного курения MSDN и других источников так и не получилось. Пока я научился криво извлекать имена Storage'й (или Stream'ов ? Этот момент тоже непонятен). Что делать дальше, чтобы получить данные Stream'ов и сопоставить их с именами файлов в папке, пока не соображу...
- Код: Выделить всё
Enum COM_HRESULT
S_OK = 0& ' усё окейжешь
STG_E_INVALIDFUNCTION = &H80030001 ' Indicates that the grfMode is set to STGM_DELETEONRELEASE (StgOpenStorageEx&)
' Unable to perform requested operation.
STG_E_FILENOTFOUND = &H80030002 'could not be found.
STG_E_PATHNOTFOUND = &H80030003 'The path %1 could not be found.
STG_E_TOOMANYOPENFILES = &H80030004 ' There are insufficient resources to open another file.
STG_E_ACCESSDENIED = &H80030005 ' Access Denied.
STG_E_INVALIDHANDLE = &H80030006 ' Attempted an operation on an invalid object.
STG_E_INSUFFICIENTMEMORY = &H80030008 ' There is insufficient memory available to complete operation.
STG_E_INVALIDPOINTER = &H80030009 ' Indicates an invalid pointer in the ppObjectOpen parameter (StgOpenStorageEx&)
STG_E_NOMOREFILES = &H80030012 ' There are no more entries to return.
STG_E_DISKISWRITEPROTECTED = &H80030013 'Disk is write-protected.
STG_E_SEEKERROR = &H80030019 'An error occurred during a seek operation.
STG_E_WRITEFAULT = &H8003001D 'A disk error occurred during a write operation.
STG_E_READFAULT = &H8003001E 'A disk error occurred during a read operation.
STG_E_SHAREVIOLATION = &H80030020 ' A share violation has occurred.
STG_E_LOCKVIOLATION = &H80030021 ' Indicates that access was denied because another caller has the file open and locked
STG_E_FILEALREADYEXISTS = &H80030050 'already exists.
STG_E_INVALIDPARAMETER = &H80030057 ' Indicates an invalid value for the grfAttrs, reserved1, reserved2, grfMode, or stgfmt parameters.
' Can occur if the FILE_FLAG_NO_BUFFERING flag is specified for grfAttrs,
' but the sector size of the file is not an integer multiple of the sector size of the underlying disk
' (StgOpenStorageEx&)
STG_E_MEDIUMFULL = &H80030070 'There is insufficient disk space to complete operation.
STG_E_PROPSETMISMATCHED = &H800300F0 ' Illegal write of non-simple property to simple property set.
STG_E_ABNORMALAPIEXIT = &H800300FA 'An API call exited abnormally.
STG_E_INVALIDHEADER = &H800300FB 'The file %1 is not a valid compound file.
STG_E_INVALIDNAME = &H800300FC 'Indicates an invalid name in the pwcsName parameter (StgOpenStorageEx&)
STG_E_UNKNOWN = &H800300FD 'An unexpected error occurred.
STG_E_UNIMPLEMENTEDFUNCTION = &H800300FE ' That function is not implemented.
STG_E_INVALIDFLAG = &H800300FF ' Indicates an invalid flag combination in the grfMode pointer;
' this includes both the STGM_DELETEONRELEASE and STGM_CONVERT flag.
' (StgOpenStorageEx&)
STG_E_INUSE = &H80030100 ' Attempted to use an object that is busy.
STG_E_NOTCURRENT = &H80030101 'The storage has been changed since the last commit.
STG_E_REVERTED = &H80030102 'Attempted to use an object that has ceased to exist.
STG_E_CANTSAVE = &H80030103 'Can 't save.
STG_E_OLDFORMAT = &H80030104 'The compound file %1 was produced with an incompatible version of storage.
STG_E_OLDDLL = &H80030105 'The compound file %1 was produced with a newer version of storage.
STG_E_SHAREREQUIRED = &H80030106 'Share.exe or equivalent is required for operation.
STG_E_NOTFILEBASEDSTORAGE = &H80030107 'Illegal operation called on non-file based storage.
STG_E_EXTANTMARSHALLINGS = &H80030108 'Illegal operation called on object with extant marshallings.
STG_E_DOCFILECORRUPT = &H80030109 ' The docfile has been corrupted.
STG_E_BADBASEADDRESS = &H80030110 ' OLE32.DLL has been loaded at the wrong address.
STG_E_DOCFILETOOLARGE = &H80030111 'The compound file is too large for the current implementation
STG_E_NOTSIMPLEFORMAT = &H80030112 'The compound file was not created with the STGM_SIMPLE flag
STG_E_INCOMPLETE = &H80030201 ' The file download was aborted abnormally. The file is incomplete.
STG_E_TERMINATED = &H80030202 'The file download has been terminated.
STG_S_CONVERTED = &H30200 'The underlying file was converted to compound file format.
STG_S_BLOCK = &H30201 'The storage operation should block until more data is available.
STG_S_RETRYNOW = &H30202 'The storage operation should retry immediately.
STG_S_MONITORING = &H30203 'The notified event sink will not influence the storage operation.
STG_S_MULTIPLEOPENS = &H30204 'Multiple opens prevent consolidated. (commit succeeded).
STG_S_CONSOLIDATIONFAILED = &H30205 ' Consolidation of the storage file failed. (commit succeeded).
STG_S_CANNOTCONSOLIDATE = &H30206 'Consolidation of the storage file is inappropriate. (commit succeeded).
E_NOINTERFACE = &H80004002 ' Indicates that the specified interface is not supported
End Enum
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Private Type STGOPTIONS
usVersion As Integer
reserved As Integer
ulSectorSize As Long
pwcsTemplateFile As String
End Type
Enum STGFMT
STGFMT_STORAGE = 0
STGFMT_FILE = 3
STGFMT_ANY = 4
STGFMT_DOCFILE = 5
End Enum
Private Declare Sub RtlMoveMemory Lib "kernel32" _
(ByVal hpvDest As Long, _
ByVal hpvSource As Long, _
ByVal cbCopy As Long)
Private Declare Function IIDFromString Lib "ole32" _
(ByVal lpszIID As Long, _
iid As GUID) As Long
Private Declare Function StgOpenStorageEx& Lib "ole32" _
(ByVal pwcsName As Long, _
ByVal grfMode As Long, _
ByVal StgFormat As STGFMT, _
ByVal grfAttrs As Long, _
pStgOptions As STGOPTIONS, _
ByVal reserved As Long, _
riid As GUID, _
ppObjectOpen As Any)
Private tsOptions As STGOPTIONS
Private ThumbStorage As IStorage
Private stgDATA As STATSTG
Private StgElement As IEnumSTATSTG '
Private Const IIDSTR_IStorage = "{0000000B-0000-0000-C000-000000000046}"
Private IID_IStorage As GUID
Option Explicit
Private Sub Command1_Click()
Dim RETVAL As Long
Dim ThumbFilePath As String
' подготовка параметров
ThumbFilePath = "D:\Graphics\thumbs.db"
IIDFromString StrPtr(IIDSTR_IStorage), IID_IStorage
tsOptions.usVersion = 1
tsOptions.ulSectorSize = 512
RETVAL = StgOpenStorageEx(ByVal StrPtr(ThumbFilePath), _
ByVal STGM_READ Or STGM_SHARE_EXCLUSIVE, _
ByVal STGFMT_DOCFILE, _
ByVal 0, _
tsOptions, _
ByVal 0, _
IID_IStorage, _
ThumbStorage)
If RETVAL = S_OK Then
Dim tName As String
tName = Space$(32) ' буфер под имя
Set StgElement = ThumbStorage.EnumElements ' ([0], [0], [0])
Do
RETVAL = StgElement.Next(1, stgDATA, 0)
If RETVAL = S_OK Then
RtlMoveMemory ByVal StrPtr(tName), ByVal stgDATA.pwcsName, ByVal 32
Debug.Print tName, Hex(stgDATA.cbSize)
Else
Exit Do
End If
Loop 'While RETVAL = S_OK
Set StgElement = Nothing
Set ThumbStorage = Nothing
Else
Debug.Print "Hex-код ошибки : " & Hex(RETVAL)
End If
End Sub
Описание интерфейсов беру в olelib.tlb