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

IStorage and IEnumSTATSTG

Hello,

I've written a wrapper for IStorage and I know the
majority of the code is working fine.

The only issue is with EnumElements. When its called the
function itself throws a COM Exception with the message
Invalid Pointer error.

My only guesses are that somehow my Interface declaration
of IEnumSTATSTG is incorrect or that the use of IntPtr is
incorrect for the void * used in EnumElements.

Is there another way to declare void * other than IntPtr.

If anybody can give me some help it would be greatly
appreciated.

CodeSnippet below

My IStorage is declared as

[ComImport]
InterfaceType(ComInterfaceType.InterfaceIsUnknown) ,
Guid("0000000b-0000-0000-C000-000000000046)]
public interface UCOMIStorage
{
...

int EnumElements(
int reserved1,
IntPtr reserved2,
int reserved3,
out UCOMIEnumSTATSTG
);

...
}

My IEnumSTATSTG is declared as

[ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ),
Guid("0000000d-0000-0000-C000-000000000046)]
public interface UCOMIEnumSTATSTG
{
...
}

The call to EnumElements called from a successfully opened
IStorage file is

UCOMIEnumSTATSTG IEnum;

int hRC = IStorageFile.EnumElements(0,IntPtr.Zero,0, out
IEnum);
Nov 15 '05 #1
4 5343
Darren,
int EnumElements(
int reserved1,
IntPtr reserved2,
int reserved3,
out UCOMIEnumSTATSTG
);


You should either apply the PreserveSig attribute to the method (if
you want to check the HRESULT yourself) or change the return type to
void. You could also, if you find it more convenient, change the
signature to

UCOMIEnumSTATSTG EnumElements(
int reserved1,
IntPtr reserved2,
int reserved3
);

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2
Hello Mattia

Tried all three options and still no joy, I still get Invalid Pointer erro

[PreserveSig
int EnumElements(int reserved1, IntPtr reserved2, int reserved3, out UCOMIEnumSTATSTG)

void EnumElements(int reserved1, IntPtr reserved2, int reserved3, out UCOMIEnumSTATSTG)

UCOMIEnumSTATSTG EnumElements(int reserved1, IntPtr reserved2, int reserved3)

Any more ideas? Has it got to do with IntPtr
Cheer
Darre
----- Mattias Sjögren wrote: ----

Darren
int EnumElements
int reserved1
IntPtr reserved2
int reserved3
out UCOMIEnumSTATST
)


You should either apply the PreserveSig attribute to the method (i
you want to check the HRESULT yourself) or change the return type t
void. You could also, if you find it more convenient, change th
signature t

UCOMIEnumSTATSTG EnumElements
int reserved1
IntPtr reserved2
int reserved
)

Mattia

--
Mattias Sjögren [MVP] mattias @ mvps.or
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.co
Please reply only to the newsgroup

Nov 15 '05 #3
Darren,
Tried all three options and still no joy, I still get Invalid Pointer error


Can you post the entire interface declaration? The only other possible
cause I can think of is if you're missing some method or have placed
them in the wrong order.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #4
Mattias,

No need as you provided the solution already

"placed them in the wrong order"

Obviously missed this important bit when reading MSDN.

Thankyou for all your help.

Cheers
Darren Mann
Nov 15 '05 #5

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

Similar topics

0
by: Ram | last post by:
I need to serialise COM object members. Cannot be directly done through serialise() attribute, Has anybody worked with IStorage for storing in c#? How to get the IStorage and IStream Interface....
16
by: Dave | last post by:
I'm having a problem trying to set up code in VB to handle the case where an argument in an API definition is defined as a pointer to a pointer. An excerpt from the API's definition is: void...
0
by: tonylc | last post by:
This is relating to the whole concept of burning a CD and using IJolietDiscMaster to use AddData(). If I just need to set IStorage to a specific file so that I can set it in the staging area. ...
2
by: eric.houghland | last post by:
Hello, I've read quite a bit about implementing this interface in .NET and believe I have a good start. I am able to use StgIsStorageFile, StgCreateStorage and StgOpenStorage. I am now...
6
by: KWienhold | last post by:
I'm currently working on a project in C# (VS 2003 SP1, .Net 1.1) that utilizes IStream/IStorage COM-Elements. Up to now I have gotten everything to work to my satisfaction, but now I have come...
2
by: Steven Nagy | last post by:
Hi all, I need to be able to take messages that have been saved from Outlook (*.msg) and read them into a C# application (think of it as workflow management). But these msg files are pretty...
7
by: Russell Mangel | last post by:
/* Hi, I am trying to hold a reference to un-managed pointer IStorage. The client/callers will make many accesses to IStorage, but only in-directly. For performance reasons IStorage needs to...
4
by: Ralf | last post by:
Hallo, I'm trying to call a COM function from C#. The function has a parameter from the type array of IStream* (IStream**). The COM component (out-proc-server (.exe)) has the following code: ...
4
by: bhumesh | last post by:
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.