473,408 Members | 1,700 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,408 software developers and data experts.

problem using StgOpenStorage()

Hello, I am using the Marshalling of StgOpenStorage in my program. It is giving me the error Error as: The type or namespace name 'IStorage' could not be found (are you missing a using directive or an assembly reference?). Can I have a solution for this, please?
May 6 '08 #1
4 3897
r035198x
13,262 8TB
Hello, I am using the Marshalling of StgOpenStorage in my program. It is giving me the error Error as: The type or namespace name 'IStorage' could not be found (are you missing a using directive or an assembly reference?). Can I have a solution for this, please?
The ref pages say you need Ole32.dll
May 6 '08 #2
The ref pages say you need Ole32.dll
But here I am already calling the function as below:
[DllImport("ole32.dll")]
static extern int StgOpenStorage(
[MarshalAs(UnmanagedType.LPWStr)] string pwcsName
, IStorage pstgPriority
, STGM grfMode // Access Method (uint)
, IntPtr snbExclude // Must be NULL
, uint reserved // Reserved
, out IStorage ppstgOpen); // Returned Storage

So what could be the problem? The error is also raised on STGM enum. Am I supposed to give additional import statements? Please reply.
May 6 '08 #3
You must define IStorage using another declaration - here is a VB version that I once wrote in one of my apps;

Expand|Select|Wrap|Line Numbers
  1. <ComImportAttribute(), ComConversionLoss(), Guid("0000000b-0000-0000-c000-000000000046"), _
  2. InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
  3. Friend Interface IStorage
  4.     ' Warning: all online examples of IStorage in VB.NET use "Sub" instead of "Function" - that will not work!
  5.     Function CreateStream(ByVal pwcsName As String, ByVal grfMode As Integer, ByVal reserved1 As Integer, ByVal reserved2 As Integer, <Out()> ByRef ppstm As ComTypes.IStream) As Integer
  6.     Function OpenStream(ByVal pwcsName As String, ByVal reserved1 As IntPtr, ByVal grfMode As Integer, ByVal reserved2 As Integer, <Out()> ByRef ppstm As ComTypes.IStream) As Integer
  7.     Function CreateStorage(ByVal pwcsName As String, ByVal grfMode As Integer, ByVal reserved1 As Integer, ByVal reserved2 As Integer, <Out()> ByRef ppstg As IStorage) As Integer
  8.     Function OpenStorage(ByVal pwcsName As String, ByVal pstgPriority As IStorage, ByVal grfMode As Integer, ByVal snbExclude As tagRemSNB, ByVal reserved As Integer, <Out()> ByRef ppstg As IStorage) As Integer
  9.     Function CopyTo(ByVal ciidExclude As Integer, ByRef rgiidExclude() As Guid, ByRef snbExclude As tagRemSNB, ByVal pstgDest As IStorage) As Integer
  10.     Function MoveElementTo(ByVal pwcsName As String, ByVal pstgDest As IStorage, ByVal pwcsNewName As String, ByVal grfFlags As Integer) As Integer
  11.     Function Commit(ByVal grfCommitFlags As Integer) As Integer
  12.     Function Revert() As Integer
  13.     Function EnumElements(ByVal reserved1 As Integer, ByVal reserved2 As IntPtr, ByVal reserved3 As Integer, <Out()> ByRef ppenum As IEnumSTATSTG) As Integer
  14.     Function DestroyElement(ByVal pwcsName As String) As Integer
  15.     Function RenameElement(ByVal pwcsOldName As String, ByVal pwcsNewName As String) As Integer
  16.     Function SetElementTimes(ByVal pwcsName As String, ByRef pctime As ComTypes.FILETIME, ByRef patime As ComTypes.FILETIME, ByRef pmtime As ComTypes.FILETIME) As Integer
  17.     Function SetClass(ByRef clsid As Guid) As Integer
  18.     Function SetStateBits(ByVal grfStateBits As Integer, ByVal grfMask As Integer) As Integer
  19.     Function Stat(<Out()> ByRef pstatstg As ComTypes.STATSTG, ByVal grfStatFlag As Integer) As Integer
  20. End Interface
  21.  
Sep 11 '09 #4
Plater
7,872 Expert 4TB
If you put your cursor over IStorage, the last letter will probably be underlined, which will give you a little drop down box. You get to pick if you want to add the namespace or enter a full reference to the class
Sep 11 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Aaron Prohaska | last post by:
I have just run into a problem where I have a page that posts back to itself to execute code, except when the page does the post back it somehow executes code that is in our home page for the site....
0
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent...
0
by: crawlerxp | last post by:
This is the problem: I do not get the output I need when encoding and decoding data using rijndael alghoritm. Look at the code and see what the problem is actually: Please paste this code into...
4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.