Dave,
I got the following StgCreateStorageEx to work, which is based on the one of
your earlier posts.
#Region " Structured Storage definitions "
' Storage instantiation modes
Public Enum STGM As Integer
DIRECT = &H0L
TRANSACTED = &H10000L
SIMPLE = &H8000000L
READ = &H0L
WRITE = &H1L
READWRITE = &H2L
SHARE_DENY_NONE = &H40L
SHARE_DENY_READ = &H30L
SHARE_DENY_WRITE = &H20L
SHARE_EXCLUSIVE = &H10L
PRIORITY = &H40000L
DELETEONRELEASE = &H4000000L
NOSCRATCH = &H100000L
CREATE = &H1000L
CONVERT = &H20000L
FAILIFTHERE = &H0L
NOSNAPSHOT = &H200000L
DIRECT_SWMR = &H400000L
End Enum
Public Enum STGFMT As Integer
STORAGE = 0
NATIVE = 1
FILE = 3
ANY = 4
DOCFILE = 5
End Enum
<PreserveSig()> _
Declare Auto Function StgCreateStorageEx Lib "ole32.dll" ( _
<MarshalAs(UnmanagedType.LPWStr)> ByVal pwcsName As String, _
ByVal grfMode As STGM, _
ByVal stgfmt As STGFMT, _
ByVal grfAttrs As Int32, _
ByVal pStgOptions As IntPtr, _
ByVal reserved As IntPtr, _
<[In]()> ByRef riid As Guid, _
<MarshalAs(UnmanagedType.IUnknown)> ByRef ppObjectOpen As Object) As
Integer
#End Region
Public Shared Sub Main()
Dim IID_IPropertySetStorage As New
Guid("0000013A-0000-0000-C000-000000000046")
Dim hr As Integer
Dim pPropSetStg As Object
hr = StgCreateStorageEx("WriteRead.stg", _
STGM.CREATE Or STGM.SHARE_EXCLUSIVE Or
STGM.READWRITE, _
STGFMT.STORAGE, _
0, IntPtr.Zero, IntPtr.Zero, _
IID_IPropertySetStorage, _
pPropSetStg)
End Sub
Notice that I changed pStgOptions to be an IntPtr and pass IntPtr.Zero
(effectively making it a C++ NULL). I do not have a working sample using an
actual STGOPTIONS structure.
To actually use pPropSetStg you will need to have the IStorage interface
properly defined and cast the pPropSetStg variable to a variable of
IStorage.
Hope this helps
Jay
Dave said:
Has anyone out there managed to create a structured storage file using pure
VB.Net? Specifically; with the API function StgCreateStorageEx? If so,
could you post a working example here please. One that can be pasted
into
a
VB.Net project and run.
Thanks
Dave