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?
problem using StgOpenStorage()
Collapse
X
-
-
The ref pages say you need Ole32.dllOriginally posted by bhumeshHello, 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? -
But here I am already calling the function as below:Originally posted by r035198xThe ref pages say you need Ole32.dll
[DllImport("ole3 2.dll")]
static extern int StgOpenStorage(
[MarshalAs(Unman agedType.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.Comment
-
You must define IStorage using another declaration - here is a VB version that I once wrote in one of my apps;
Code:<ComImportAttribute(), ComConversionLoss(), Guid("0000000b-0000-0000-c000-000000000046"), _ InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _ Friend Interface IStorage ' Warning: all online examples of IStorage in VB.NET use "Sub" instead of "Function" - that will not work! 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 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 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 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 Function CopyTo(ByVal ciidExclude As Integer, ByRef rgiidExclude() As Guid, ByRef snbExclude As tagRemSNB, ByVal pstgDest As IStorage) As Integer Function MoveElementTo(ByVal pwcsName As String, ByVal pstgDest As IStorage, ByVal pwcsNewName As String, ByVal grfFlags As Integer) As Integer Function Commit(ByVal grfCommitFlags As Integer) As Integer Function Revert() As Integer Function EnumElements(ByVal reserved1 As Integer, ByVal reserved2 As IntPtr, ByVal reserved3 As Integer, <Out()> ByRef ppenum As IEnumSTATSTG) As Integer Function DestroyElement(ByVal pwcsName As String) As Integer Function RenameElement(ByVal pwcsOldName As String, ByVal pwcsNewName As String) As Integer Function SetElementTimes(ByVal pwcsName As String, ByRef pctime As ComTypes.FILETIME, ByRef patime As ComTypes.FILETIME, ByRef pmtime As ComTypes.FILETIME) As Integer Function SetClass(ByRef clsid As Guid) As Integer Function SetStateBits(ByVal grfStateBits As Integer, ByVal grfMask As Integer) As Integer Function Stat(<Out()> ByRef pstatstg As ComTypes.STATSTG, ByVal grfStatFlag As Integer) As Integer End InterfaceComment
Comment