Hi again Jay.
Ok Here are some snippets from my code.
First the definition of the interface IStorage:
__________________________________________________ ______________
<Guid("0000000B-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), ComConversionLoss()> _
Public Interface IStorage
Function Commit(ByVal grfCommitFlags As STGC) As Integer
Function CopyTo(ByVal ciidExclude As Integer, ByVal rgiidExclude As
LPGUID, ByVal snbExclude As IntPtr, ByVal pstgDest As IStorage) As Integer
Function CreateStorage(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsName As
String, ByVal grfMode As STGM, ByVal reserved1 As Integer, ByVal reserved2
As Integer, ByRef ppstg As IStorage) As Integer
Function CreateStream(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsName As
String, ByVal grfMode As STGM, ByVal reserved1 As Integer, ByVal reserved2
As Integer, ByRef ppstm As IStream) As Integer
Function DestroyElement(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsName
As String) As Integer
Function EnumElements(ByVal reserved1 As Integer, ByVal reserved2 As
IntPtr, ByVal reserved3 As Integer, ByRef ppenum As IEnumSTATSTG) As Integer
Function MoveElementTo(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsName As
String, ByVal pstgDest As IStorage, <MarshalAs(UnmanagedType.LPWStr)> ByVal
pwcsNewName As String, ByVal grfFlags As STGMOVE) As Integer
Function OpenStorage(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsName As
String, ByVal pstgPriority As IntPtr, ByVal grfMode As STGM, ByVal
snbExclude As IntPtr, ByVal reserved As Integer, ByRef ppstg As IStorage) As
Integer
Function OpenStream(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsName As
String, ByVal reserved1 As IntPtr, ByVal grfMode As STGM, ByVal reserved2 As
Integer, ByRef ppstm As IStream) As Integer
Function RenameElement(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsOldName
As String, <MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsNewName As String) As
Integer
Function Revert() As Integer
Function SetClass(ByVal clsid As LPGUID) As Integer
Function SetElementTimes(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsName
As String, ByVal pctime As FILETIME, ByVal patime As FILETIME, ByVal pmtime
As FILETIME) As Integer
Function SetStateBits(ByVal grfStateBits As Integer, ByVal grfMask As
Integer) As Integer
Function Stat(ByRef pstatstg As STATSTG, ByVal grfStatFlag As STATFLAG) As
Integer
End Interface
__________________________________________________ _____________________
Next, the declaration of the StgCreateStorageEx
__________________________________________________ ______________________
Declare Function StgCreateStorageEx Lib "ole32.dll" ( _
<MarshalAs(UnmanagedType.LPWStr)> ByRef pwcsName As String, _
ByVal grfMode As Int32, _
ByVal stgfmt As Int32, _
ByVal grfAttrs As Int32, _
<MarshalAs(UnmanagedType.Struct)> ByRef pStgOptions As STGOPTIONS, _
ByVal reserved As Int32, _
ByVal riid As Guid, _
ByRef ppObjectOpen As Object) As Integer
__________________________________________________ _____________________
Finaly, the call itself
__________________________________________________ _____________________
Dim objIStorage As IStorage()
Dim R As Integer
R = StgCreateStorageEx(PATH, _
STGM.STGM_READWRITE Or STGM.STGM_SHARE_EXCLUSIVE, _
STGFMT.STGFMT_ANY, _
0, _
StgOptions, _
0, _
IID_Storage, _
objIStorage)
__________________________________________________ ______________________
The call goes through but the function returns a STG_E_INVALIDPOINTER error
value.
FYI: As I mentioned, I crossposted this in the Interop bucket. So far I've
gotten ziltch from that group. But then again they don't get out of bed
until 4:00 PM. Just kidding.
Thanks again for your interest.
Dave
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Dave,
Read Adam Nathan's book, he explains what you need to do to get the
"pointer to interface pointer variable" magic to work. Plus he gives you the
definition for StgCreateStorageEx!
Note this is COM, as you have a pointer to an interface pointer, the
interface pointer is a COM interface!
Basically ppObjectOpen is ByRef Object, with a
MarshalAs(UnmanagedType.IUnknown) Attribute.
Something to the effect, you will need to double check syntax:
Declare Sub StgCreateStorageEx(... <MarshalAs(UnmanagedType.IUnknown)>
ByRef ppObjectOpen As Object)
However to actually use the interface returned in ppObjectOpen, you will
need to define the IStorage interface.
Once you have the IStorage interface defined, you define a variable of
type IStorage and use it.
After you get StgCreateStorageEx, defining the IStorage interface is the
tricky part.
Hope this helps
Jay