Next method in shell programming

V

Vivek

Hello everyone,

I am doing shell programming in c# for an application.
I am able to enumerate the IShellFolder object with IEnumIdList. But when I
try to use Next method on it, it does not return anything. I use the
definition for ComImport as follows for this method :

[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("000214F2-0000-0000-C000-000000000046")]

[PreserveSig]
Int32 Next( UInt32 celt,
out IntPtr rgelt,
out UInt32 pceltFetched
);

Then, I call this method as:

ppenumlist.Next(2, out pidlItems, out celtFetched);

Can somebody tell, where am I wrong ? It will really be a great help !

Thanks in advance
 
G

Guest

But when I try to use Next method on it, it does not return anything.

Do you mean that pidlItems and/or celtFetched are zero after the call?
What's the return value (the HRESULT) returned by Next?

ppenumlist.Next(2, out pidlItems, out celtFetched);

The first argument should be 1 since you're not passing in an array big
enough to hold two items.


Mattias
 
V

Vivek

Excuse me. Off course, first argument is 1.

What I wanted to say is that pidlItems does not contain anything and
cetFetched is equal to zero.
 
M

Mattias Sjögren

What I wanted to say is that pidlItems does not contain anything and
cetFetched is equal to zero.

OK, I'm still curious what the return value is. That is, if you write

int hr = ppenumlist.Next(1, out pidlItems, out celtFetched);

what's the value of hr after the call?


Mattias
 
V

Vivek

Int32 hr = (-)2147467263

Vivek

Mattias Sjögren said:
OK, I'm still curious what the return value is. That is, if you write

int hr = ppenumlist.Next(1, out pidlItems, out celtFetched);

what's the value of hr after the call?
 
M

Mattias Sjögren

Int32 hr = (-)2147467263

That's 0x80004001 also known as E_NOTIMPL indicating that the method
isn't implemented. I find it hard to believe that an enumerator
wouldn't implement Next, it would make it rather useless. So my guess
is that you have declared the IEnumIDList methods in the wrong order.
The method order for all IEnum* interfaces should be Next, Skip,
Reset, Clone.


Mattias
 
V

Vivek

It works. In fact, I took the order as in shell tutorial of msdn.
Thanks you very much. It had really become a headache and I had started
depressing just because of this.

Vivek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top