Board index » Visual Studio » IShellFolder.GetUIObjectsOf fails while accessing un unistatiated object

IShellFolder.GetUIObjectsOf fails while accessing un unistatiated object

Visual Studio110
Hi all,

here I am again :-( , this turn I'm in trouble with

IShellFolder.GetUIObjectsOf, which raise an exception while accessing an

uninstantiated object (I have Italian version softwares and I litteraly

translate the error, the original error may sound a little different).



I'm using VB.Net, and I need to access ThumbImage extractor, I got

IShellFolder interface object pointing to the Directory where my file is in

(in following code it's named item), I know it' Ok since I can enumerate

contained objects through EnumObjects. Also Pidl is okay since

PathFromPidl(pidl) return a correct value. IntPtr.Zero, 1 and prgf should be

okay too :-).

So the problem seems to be IUnknown but shouldn't it be an output parameter?

Or It may be interface definition...



(by the way: how to instantiate a com object like IUnknown interface ?)



This is the code



Dim pidlPath As String = PathFromPidl(pidl)



' pidl is a relative pidl, so only the filename portion is relevant

If Path.GetFileName(pidlPath).Equals(Path.GetFileName(file)) Then

ret = True



Dim iUnk As IUnknown

' Try and get the IExtractImage interface:

Dim prgf As UInt32

Dim iidExtractImage As Guid = New

Guid("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1")

item.GetUIObjectOf(IntPtr.Zero, 1, pidl, iidExtractImage, prgf,

iUnk)



'some code

End If



Here is the interface (just the method)



<PreserveSig()>_

Function GetUIObjectOf(ByVal hwndOwner As IntPtr,

<MarshalAs(UnmanagedType.U8)>ByVal cidl As Long, ByRef apidl As IntPtr,

ByVal riid As Guid, ByRef rgfReserved As UInt32, ByRef ppv As IUnknown) As

Int32



What's wrong?



Thanks, Nicola


-
 

Re:IShellFolder.GetUIObjectsOf fails while accessing un unistatiated object

Nicola,



Quote
<PreserveSig()>_

Function GetUIObjectOf(ByVal hwndOwner As IntPtr,

<MarshalAs(UnmanagedType.U8)>ByVal cidl As Long, ByRef apidl As IntPtr,

ByVal riid As Guid, ByRef rgfReserved As UInt32, ByRef ppv As IUnknown) As

Int32



What's wrong?



cidl should be an Integer. riid should be passed ByRef.







Mattias



--

Mattias Sjögren [MVP] mattias @ mvps.org

www.msjogren.net/dotnet/">www.msjogren.net/dotnet/ | www.dotnetinterop.com">www.dotnetinterop.com

Please reply only to the newsgroup.

-