473,327 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Structured Storage using VB.Net

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
Nov 20 '05 #1
10 5608
* "Dave" <ww*@com.com> scripsit:
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.


You will find some information on how to use this function with .NET
here (there is no VB.NET sample, but maybe the code will give you an
idea on how to implement that in VB.NET or in an MC++ or C# component):

<http://groups.google.com/groups?ie=UTF-8&q=group%3A*dotnet*+StgCreateStorageEx>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Thank you Herfried

I'm sure its possible to successfully call the function in C# or C++ in the
Net environment. What I'm not sure of is, if its even possible using VB7. In
VB7 the function always returns a STG_E_INVALIDPOINTER error no matter how
its definition is set up. That means the function is being called ok but
that it doesn't like what its been passed as arguments.

Dave
Nov 20 '05 #3
* "Dave" <ww*@com.com> scripsit:
I'm sure its possible to successfully call the function in C# or C++ in the
Net environment. What I'm not sure of is, if its even possible using VB7. In
VB7 the function always returns a STG_E_INVALIDPOINTER error no matter how
its definition is set up. That means the function is being called ok but
that it doesn't like what its been passed as arguments.


Which declaration do you use? Maybe it's simpler to implement the
functionality in a MC++ or C# component that can be used by the VB.NET
application (if you are using VS.NET Professional or better).

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Herfried,
Dave posted his declaration yesterday in a long thread him & I had titled
"Pointer to a Pointer in VB".

He had some minor issues in his declaration that I pointed out, however
there is something else wrong that I did not immediately identify.

I suggested he waits until Monday and get help in the
microsoft.public.dotnet.framework.interop newsgroup as that is where the
people best able to help him hang out, and Monday he will have a better
chance of getting more experts on line.

I also referred him to Adam Nathan's book ".NET and COM - The Complete
Interoperability Guide" from SAMS press. As it actually has the definitions
printed in it, albeit in C#. However the book does have a chapter or to on
how to define the functions in both C# & VB.NET so converting the
definitions back & forth should be "easy".

Hope this helps
Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Oa*************@TK2MSFTNGP11.phx.gbl...
* "Dave" <ww*@com.com> scripsit:
I'm sure its possible to successfully call the function in C# or C++ in the Net environment. What I'm not sure of is, if its even possible using VB7. In VB7 the function always returns a STG_E_INVALIDPOINTER error no matter how its definition is set up. That means the function is being called ok but
that it doesn't like what its been passed as arguments.


Which declaration do you use? Maybe it's simpler to implement the
functionality in a MC++ or C# component that can be used by the VB.NET
application (if you are using VS.NET Professional or better).

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #5
* "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> scripsit:
Dave posted his declaration yesterday in a long thread him & I had titled
"Pointer to a Pointer in VB".


Thank you for the information. I didn't follow this thread...

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
The original question still stands.
Nov 20 '05 #7
Dave,
It seems to me that it needs to stand "down the hall" in the
microsoft.public.dotnet.framework.interop newsgroup, however I realize you
don't feel that way.

Good luck

Jay

"Dave" <ww*@com.com> wrote in message
news:iK******************@twister01.bloor.is.net.c able.rogers.com...
The original question still stands.

Nov 20 '05 #8
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" <ww*@com.com> wrote in message
news:Ce*******************@news01.bloor.is.net.cab le.rogers.com...
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

Nov 20 '05 #9
Jay

You have indeed come up with the solution. Or at least 90-95% of it anyway.
I modified my code using your suggestion and the call did in fact result in
the creation of a Structured Storage file (with a root storage) in it.

The only fly in the ointment is that even though the call worked the
pPropSetStg paramater remains as Null. This should be expected though as the
code is responsible for setting this 'pointer' to something, while the API
builds the IStructure.

I will work this some more.

As an aside, there is a message in Interop called "How To: Port HRESULT
GetCurrentSample( [out,retval] IMediaSample ** ppSample );" which is related
to this ** pointer business.

Dave

PS: I will send you an email. All is forgiven.
_________________________________________

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:ul****************@TK2MSFTNGP10.phx.gbl...
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" <ww*@com.com> wrote in message
news:Ce*******************@news01.bloor.is.net.cab le.rogers.com...
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


Nov 20 '05 #10
Dave,
If you need the pStgOptions structure I would probably overload the Declare.
One takes the Intptr and one takes the pStgOptions structure. As the
pStgOptions is only needed if you are using STGFMT_DOCFILE (see win32 API
for full info).

Hope this helps
Jay

"Dave" <ww*@com.com> wrote in message
news:8x*******************@news01.bloor.is.net.cab le.rogers.com...
Jay

You have indeed come up with the solution. Or at least 90-95% of it anyway. I modified my code using your suggestion and the call did in fact result in the creation of a Structured Storage file (with a root storage) in it.

The only fly in the ointment is that even though the call worked the
pPropSetStg paramater remains as Null. This should be expected though as the code is responsible for setting this 'pointer' to something, while the API
builds the IStructure.

I will work this some more.

As an aside, there is a message in Interop called "How To: Port HRESULT
GetCurrentSample( [out,retval] IMediaSample ** ppSample );" which is related to this ** pointer business.

Dave

PS: I will send you an email. All is forgiven.
_________________________________________

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:ul****************@TK2MSFTNGP10.phx.gbl...
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" <ww*@com.com> wrote in message
news:Ce*******************@news01.bloor.is.net.cab le.rogers.com...
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



Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: tlviewer | last post by:
hello, In honor of the chm exploit that I got hit by last week, I trying to code some ActivePython to list the directory inside a CHM. CHM is supposed to be structured storage (ITSF). If a...
3
by: Edmond Neo | last post by:
I use structured storage to store large amounts of data in various streams. I realize that I can call structured storage through a wrapper in .NET, but I'm concerned that there is a performance...
3
by: _link98 | last post by:
Running DB2 ESE V8.1.8 on WinXP. This is Fixpak 8. Have a structured-type and some methods for that type. One of my methods needs to do insert / update on tables. The type specification...
4
by: David Groves | last post by:
Are there any plans to incorporate a native C# facility to deal with the OLE Structured Storage concept? It's clumsy at best to have to construct a C++ interface to the .doc files (or any such...
1
by: Gerald Hernandez | last post by:
The .NET Framework is huge, and either this isn't in there, or I'm just missing it... Are there any built-in methods to work with OLE2 Structured Storage files? Or am I stuck with using COM...
3
by: Dwight | last post by:
I need to be able to read and create Structured Storage Files. I have not been able to find anything about this except for C++, which I do not know. currently i'm using a DOC viewer (eDoc) just to...
2
by: ERE | last post by:
I'd like to encapsulate several files -- mostly graphics files -- as a single file. Does .NET provide a convenient way to do this? COM provided structured storage -- but I definitely don't want...
3
by: Gregory Gadow | last post by:
Is there a way to create structured files in .NET 2.0? Essentially, I want to take a hierarchic web site and convert it to a single, navigatable file similar to the compiled help, but using my own...
0
by: John Levin | last post by:
I'm trying to port Edanmo's OLE Storage class (http://www.mvps.org/emorcillo/en/code/grl/storage.shtml) to x64. After my modifications, it still works fine under x86. However, I'm getting a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.