I can't get this damned IEnumIDList thing to work correctly. I've got the
desktop folder as an IShellObject (which I've verified by being able to get
the display name etc. from it). I can also get a pointer to the IEnumIDList
object via. GetIEnum. It even allows me to execute the "Fetch" method on
the interface (changed from "Next" because next is a VB keyword - in any
case, its just a function pointer in the VTable). But COM_pIDL always
returns zero in this case. I would expect at least a pointer to some child
pidls or something.
I know this is "VB", but I seem to be doing everything in the same was as
the C# and C++ demos I've seen. Maybe you can spot something dodgy here? :
(apologies for the cross post to the interop group but I'm not sure if you
guys check both)
Public Function GetDesktop() As ShellFolder
' Get the root folder from the shell
Dim COM_theRoot As ShellLib.IShellFolder
COM_theRoot = ShellLib.ShellFunctions.GetDesktopFolder()
If COM_theRoot Is Nothing Then
Exit Function
End If
' the above works, I've verified it returns the "Desktop" IShellFolder
Dim COM_theEnum As ShellLib.IEnumIDList =
ShellLib.ShellFunctions.GetIEnum(COM_theRoot)
Dim COM_pIDL As IntPtr
Try
Do
COM_theEnum.Fetch(1, COM_pIDL, 0)
Debug.WriteLine(COM_pIDL.ToString())
Loop While not COM_pIDL.Equals(IntPtr.Zero)
Catch Ex As Exception
End Try
End Function
' /////////////////////////////////////////////////////////////////////////
' //
' // IEnumIDList
' //
' /////////////////////////////////////////////////////////////////////////
<ComImportAttribute(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown ),
Guid("000214F2-0000-0000-C000-000000000046")> _
Public Interface IEnumIDList
<PreserveSig()> _
Function Fetch(ByVal cElt As Integer, ByVal rGelt As IntPtr, ByRef
pCeltFetched As Integer) As Integer
<PreserveSig()> _
Sub Skip(ByVal cElt As Integer)
<PreserveSig()> _
Sub Reset()
<PreserveSig()> _
Sub Clone(ByRef pEnum As IEnumIDList)
End Interface 4 2223
Robin,
Try the following (untested): <ComImportAttribute(),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), Guid("000214F2-0000-0000-C000-000000000046")> _ Public Interface IEnumIDList
<PreserveSig()> _ Function [Next](ByVal cElt As Integer, ByRef rGelt As IntPtr, ByRef pCeltFetched As Integer) As Integer
<PreserveSig()> _ Sub Skip(ByVal cElt As Integer)
<PreserveSig()> _ Sub Reset()
<PreserveSig()> _ Sub Clone(ByRef pEnum As IEnumIDList)
End Interface
By making rGelt ByVal you were effectively making it input only, you need to
make it ByRef to allow it to be "returned", remember its LPITEMIDLIST* (a
pointer to a long pointer to an ITEMIDLIST).
Also, notice that I named the Next method [Next], this allows a keyword to
be used as an identifier, when using next with an actual object, the [] are
not needed...
Note: I did not test the above...
Hope this helps
Jay
"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:c0******************@news.demon.co.uk... I can't get this damned IEnumIDList thing to work correctly. I've got the desktop folder as an IShellObject (which I've verified by being able to
get the display name etc. from it). I can also get a pointer to the
IEnumIDList object via. GetIEnum. It even allows me to execute the "Fetch" method on the interface (changed from "Next" because next is a VB keyword - in any case, its just a function pointer in the VTable). But COM_pIDL always returns zero in this case. I would expect at least a pointer to some
child pidls or something.
I know this is "VB", but I seem to be doing everything in the same was as the C# and C++ demos I've seen. Maybe you can spot something dodgy here?
: (apologies for the cross post to the interop group but I'm not sure if you guys check both)
Public Function GetDesktop() As ShellFolder
' Get the root folder from the shell
Dim COM_theRoot As ShellLib.IShellFolder
COM_theRoot = ShellLib.ShellFunctions.GetDesktopFolder() If COM_theRoot Is Nothing Then Exit Function End If
' the above works, I've verified it returns the "Desktop" IShellFolder
Dim COM_theEnum As ShellLib.IEnumIDList = ShellLib.ShellFunctions.GetIEnum(COM_theRoot) Dim COM_pIDL As IntPtr
Try Do COM_theEnum.Fetch(1, COM_pIDL, 0) Debug.WriteLine(COM_pIDL.ToString()) Loop While not COM_pIDL.Equals(IntPtr.Zero)
Catch Ex As Exception
End Try End Function
'
///////////////////////////////////////////////////////////////////////// ' // ' // IEnumIDList ' // '
///////////////////////////////////////////////////////////////////////// <ComImportAttribute(),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), Guid("000214F2-0000-0000-C000-000000000046")> _ Public Interface IEnumIDList
<PreserveSig()> _ Function Fetch(ByVal cElt As Integer, ByVal rGelt As IntPtr, ByRef pCeltFetched As Integer) As Integer
<PreserveSig()> _ Sub Skip(ByVal cElt As Integer)
<PreserveSig()> _ Sub Reset()
<PreserveSig()> _ Sub Clone(ByRef pEnum As IEnumIDList)
End Interface
Yes, I noticed this and tried it byref too, but still the same result.
Perhaps the way I get the interface is incorrect? Here it is (for some
reason, my namespace ShellLib, contains IEnumIDList, but shellEnumType is
returning "nothing"??).
Public Shared Function GetIEnum(ByRef theFolder As IShellFolder) As
IEnumIDList
Dim ptrRet As IntPtr
theFolder.EnumObjects(IntPtr.Zero, 0, ptrRet)
Dim shellEnumType As System.Type =
System.Type.GetType("ShellLib.IEnumIDList")
Dim obj As [Object] = Marshal.GetTypedObjectForIUnknown(CType(ptrRet,
IntPtr), shellEnumType)
Dim iEnumFolder As IEnumIDList = CType(obj, IEnumIDList)
Return iEnumFolder
End Function
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... Robin, Try the following (untested):
<ComImportAttribute(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), Guid("000214F2-0000-0000-C000-000000000046")> _ Public Interface IEnumIDList
<PreserveSig()> _ Function [Next](ByVal cElt As Integer, ByRef rGelt As IntPtr, ByRef pCeltFetched As Integer) As Integer
<PreserveSig()> _ Sub Skip(ByVal cElt As Integer)
<PreserveSig()> _ Sub Reset()
<PreserveSig()> _ Sub Clone(ByRef pEnum As IEnumIDList)
End Interface
By making rGelt ByVal you were effectively making it input only, you need
to make it ByRef to allow it to be "returned", remember its LPITEMIDLIST* (a pointer to a long pointer to an ITEMIDLIST).
Also, notice that I named the Next method [Next], this allows a keyword to be used as an identifier, when using next with an actual object, the []
are not needed...
Note: I did not test the above...
Hope this helps Jay
"Robin Tucker" <id*************************@reallyidont.com> wrote in message news:c0******************@news.demon.co.uk... I can't get this damned IEnumIDList thing to work correctly. I've got
the desktop folder as an IShellObject (which I've verified by being able to get the display name etc. from it). I can also get a pointer to the IEnumIDList object via. GetIEnum. It even allows me to execute the "Fetch" method
on the interface (changed from "Next" because next is a VB keyword - in any case, its just a function pointer in the VTable). But COM_pIDL always returns zero in this case. I would expect at least a pointer to some child pidls or something.
I know this is "VB", but I seem to be doing everything in the same was
as the C# and C++ demos I've seen. Maybe you can spot something dodgy
here? : (apologies for the cross post to the interop group but I'm not sure if
you guys check both)
Public Function GetDesktop() As ShellFolder
' Get the root folder from the shell
Dim COM_theRoot As ShellLib.IShellFolder
COM_theRoot = ShellLib.ShellFunctions.GetDesktopFolder() If COM_theRoot Is Nothing Then Exit Function End If
' the above works, I've verified it returns the "Desktop"
IShellFolder Dim COM_theEnum As ShellLib.IEnumIDList = ShellLib.ShellFunctions.GetIEnum(COM_theRoot) Dim COM_pIDL As IntPtr
Try Do COM_theEnum.Fetch(1, COM_pIDL, 0) Debug.WriteLine(COM_pIDL.ToString()) Loop While not COM_pIDL.Equals(IntPtr.Zero)
Catch Ex As Exception
End Try End Function
' ///////////////////////////////////////////////////////////////////////// ' // ' // IEnumIDList ' // ' ///////////////////////////////////////////////////////////////////////// <ComImportAttribute(),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), Guid("000214F2-0000-0000-C000-000000000046")> _ Public Interface IEnumIDList
<PreserveSig()> _ Function Fetch(ByVal cElt As Integer, ByVal rGelt As IntPtr, ByRef pCeltFetched As Integer) As Integer
<PreserveSig()> _ Sub Skip(ByVal cElt As Integer)
<PreserveSig()> _ Sub Reset()
<PreserveSig()> _ Sub Clone(ByRef pEnum As IEnumIDList)
End Interface
My dumb mistake (apart from the byref faux pas earlier),
I was passing in 0 for flags, rather than SHCONTF_FOLDERS! It works now,
I've got more piddles than I know what to do with.
theFolder.EnumObjects(IntPtr.Zero, ShellAPI.SHCONTF.SHCONTF_FOLDERS, ptrRet)
"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:c0*******************@news.demon.co.uk... Yes, I noticed this and tried it byref too, but still the same result. Perhaps the way I get the interface is incorrect? Here it is (for some reason, my namespace ShellLib, contains IEnumIDList, but shellEnumType is returning "nothing"??).
Public Shared Function GetIEnum(ByRef theFolder As IShellFolder) As IEnumIDList
Dim ptrRet As IntPtr
theFolder.EnumObjects(IntPtr.Zero, 0, ptrRet)
Dim shellEnumType As System.Type = System.Type.GetType("ShellLib.IEnumIDList") Dim obj As [Object] = Marshal.GetTypedObjectForIUnknown(CType(ptrRet, IntPtr), shellEnumType) Dim iEnumFolder As IEnumIDList = CType(obj, IEnumIDList)
Return iEnumFolder
End Function
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:%2***************@tk2msftngp13.phx.gbl... Robin, Try the following (untested):
<ComImportAttribute(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), Guid("000214F2-0000-0000-C000-000000000046")> _ Public Interface IEnumIDList
<PreserveSig()> _ Function [Next](ByVal cElt As Integer, ByRef rGelt As IntPtr,
ByRef pCeltFetched As Integer) As Integer
<PreserveSig()> _ Sub Skip(ByVal cElt As Integer)
<PreserveSig()> _ Sub Reset()
<PreserveSig()> _ Sub Clone(ByRef pEnum As IEnumIDList)
End Interface
By making rGelt ByVal you were effectively making it input only, you
need to make it ByRef to allow it to be "returned", remember its LPITEMIDLIST*
(a pointer to a long pointer to an ITEMIDLIST).
Also, notice that I named the Next method [Next], this allows a keyword
to be used as an identifier, when using next with an actual object, the [] are not needed...
Note: I did not test the above...
Hope this helps Jay
"Robin Tucker" <id*************************@reallyidont.com> wrote in message news:c0******************@news.demon.co.uk... I can't get this damned IEnumIDList thing to work correctly. I've got the desktop folder as an IShellObject (which I've verified by being able
to get the display name etc. from it). I can also get a pointer to the IEnumIDList object via. GetIEnum. It even allows me to execute the "Fetch" method on the interface (changed from "Next" because next is a VB keyword - in
any case, its just a function pointer in the VTable). But COM_pIDL always returns zero in this case. I would expect at least a pointer to some child pidls or something.
I know this is "VB", but I seem to be doing everything in the same was as the C# and C++ demos I've seen. Maybe you can spot something dodgy here? : (apologies for the cross post to the interop group but I'm not sure if
you guys check both)
Public Function GetDesktop() As ShellFolder
' Get the root folder from the shell
Dim COM_theRoot As ShellLib.IShellFolder
COM_theRoot = ShellLib.ShellFunctions.GetDesktopFolder() If COM_theRoot Is Nothing Then Exit Function End If
' the above works, I've verified it returns the "Desktop" IShellFolder Dim COM_theEnum As ShellLib.IEnumIDList = ShellLib.ShellFunctions.GetIEnum(COM_theRoot) Dim COM_pIDL As IntPtr
Try Do COM_theEnum.Fetch(1, COM_pIDL, 0) Debug.WriteLine(COM_pIDL.ToString()) Loop While not COM_pIDL.Equals(IntPtr.Zero)
Catch Ex As Exception
End Try End Function
'
///////////////////////////////////////////////////////////////////////// ' // ' // IEnumIDList ' // '
///////////////////////////////////////////////////////////////////////// <ComImportAttribute(),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), Guid("000214F2-0000-0000-C000-000000000046")> _ Public Interface IEnumIDList
<PreserveSig()> _ Function Fetch(ByVal cElt As Integer, ByVal rGelt As IntPtr, ByRef pCeltFetched As Integer) As Integer
<PreserveSig()> _ Sub Skip(ByVal cElt As Integer)
<PreserveSig()> _ Sub Reset()
<PreserveSig()> _ Sub Clone(ByRef pEnum As IEnumIDList)
End Interface
Robin,
I *hate* when that (forgetting a flag) happens. :-)
Glad you got it to work.
Jay
"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:c0*******************@news.demon.co.uk... My dumb mistake (apart from the byref faux pas earlier),
I was passing in 0 for flags, rather than SHCONTF_FOLDERS! It works now, I've got more piddles than I know what to do with.
theFolder.EnumObjects(IntPtr.Zero, ShellAPI.SHCONTF.SHCONTF_FOLDERS,
ptrRet)
"Robin Tucker" <id*************************@reallyidont.com> wrote in message news:c0*******************@news.demon.co.uk... Yes, I noticed this and tried it byref too, but still the same result. Perhaps the way I get the interface is incorrect? Here it is (for some reason, my namespace ShellLib, contains IEnumIDList, but shellEnumType
is returning "nothing"??).
Public Shared Function GetIEnum(ByRef theFolder As IShellFolder) As IEnumIDList
Dim ptrRet As IntPtr
theFolder.EnumObjects(IntPtr.Zero, 0, ptrRet)
Dim shellEnumType As System.Type = System.Type.GetType("ShellLib.IEnumIDList") Dim obj As [Object] =
Marshal.GetTypedObjectForIUnknown(CType(ptrRet, IntPtr), shellEnumType) Dim iEnumFolder As IEnumIDList = CType(obj, IEnumIDList)
Return iEnumFolder
End Function
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message news:%2***************@tk2msftngp13.phx.gbl... Robin, Try the following (untested):
> <ComImportAttribute(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), > Guid("000214F2-0000-0000-C000-000000000046")> _ > Public Interface IEnumIDList > > <PreserveSig()> _ > Function [Next](ByVal cElt As Integer, ByRef rGelt As IntPtr, ByRef > pCeltFetched As Integer) As Integer > > <PreserveSig()> _ > Sub Skip(ByVal cElt As Integer) > > <PreserveSig()> _ > Sub Reset() > > <PreserveSig()> _ > Sub Clone(ByRef pEnum As IEnumIDList) > > End Interface
By making rGelt ByVal you were effectively making it input only, you need to make it ByRef to allow it to be "returned", remember its LPITEMIDLIST* (a pointer to a long pointer to an ITEMIDLIST).
Also, notice that I named the Next method [Next], this allows a
keyword to be used as an identifier, when using next with an actual object, the
[] are not needed...
Note: I did not test the above...
Hope this helps Jay
"Robin Tucker" <id*************************@reallyidont.com> wrote in message news:c0******************@news.demon.co.uk... > I can't get this damned IEnumIDList thing to work correctly. I've
got the > desktop folder as an IShellObject (which I've verified by being able to get > the display name etc. from it). I can also get a pointer to the IEnumIDList > object via. GetIEnum. It even allows me to execute the "Fetch"
method on > the interface (changed from "Next" because next is a VB keyword - in any > case, its just a function pointer in the VTable). But COM_pIDL
always > returns zero in this case. I would expect at least a pointer to
some child > pidls or something. > > I know this is "VB", but I seem to be doing everything in the same
was as > the C# and C++ demos I've seen. Maybe you can spot something dodgy here? : > > (apologies for the cross post to the interop group but I'm not sure
if you > guys check both) > > Public Function GetDesktop() As ShellFolder > > ' Get the root folder from the shell > > Dim COM_theRoot As ShellLib.IShellFolder > > COM_theRoot = ShellLib.ShellFunctions.GetDesktopFolder() > If COM_theRoot Is Nothing Then > Exit Function > End If > > ' the above works, I've verified it returns the "Desktop" IShellFolder > > Dim COM_theEnum As ShellLib.IEnumIDList = > ShellLib.ShellFunctions.GetIEnum(COM_theRoot) > Dim COM_pIDL As IntPtr > > Try > Do > COM_theEnum.Fetch(1, COM_pIDL, 0) > Debug.WriteLine(COM_pIDL.ToString()) > Loop While not COM_pIDL.Equals(IntPtr.Zero) > > Catch Ex As Exception > > End Try > End Function > > '
///////////////////////////////////////////////////////////////////////// > ' // > ' // IEnumIDList > ' // > ' ///////////////////////////////////////////////////////////////////////// > > <ComImportAttribute(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), > Guid("000214F2-0000-0000-C000-000000000046")> _ > Public Interface IEnumIDList > > <PreserveSig()> _ > Function Fetch(ByVal cElt As Integer, ByVal rGelt As IntPtr,
ByRef > pCeltFetched As Integer) As Integer > > <PreserveSig()> _ > Sub Skip(ByVal cElt As Integer) > > <PreserveSig()> _ > Sub Reset() > > <PreserveSig()> _ > Sub Clone(ByRef pEnum As IEnumIDList) > > End Interface > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jim Hubbard |
last post by:
I am reposting a portion of a thread that I am involved in under a new topic
because it seems that there are still people that believe the whole "DLL
Hell" myth.
I hope I can shed some light on...
|
by: Melinda |
last post by:
hi all,
i'm having problems with BindToObject(). when i call the method it is
throwing a System.NullReferenceException error, but i don't understand
why. what i'm trying to do is get a...
|
by: Robin Tucker |
last post by:
I need to create my own explorer-style control - I don't seem to have access
to IShellFolder - assuming I need it (which I think I do), how can this be
done? I've imported shell32.dll into my...
|
by: Robin Tucker |
last post by:
I've got this nice pidl, enumerated via. IEnumIDList on an IShellFolder (the
desktop). I know the pidl is ok, because I can list its display name and
its looking good. Now I want to go a level...
|
by: Nicola Garone |
last post by:
Hi all
I'm using VB.net. I need to define an object of type iShellFolder (since
I have to call ShGetDesktopfolder API in Shell32.dll). I've created
interop.Shell32.dll adding a reference to...
|
by: Nicola Garone |
last post by:
Hi all,
I need to enumerate pidl in a directory which I got (I think) the rigt
pidl, but I don't know how to procede.
here is a piece of code (folder is a IShellFolder object and it seems to...
|
by: Nicola Garone |
last post by:
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...
|
by: Andrius B. |
last post by:
Hi. My problem concerns vb .net 2005.
I want to use IShellFolder interface for such functions as
ParseDisplayname. But how to parse a string - folder name (I mean, adding
terminating nullchar or...
|
by: Andrius B. |
last post by:
Hi all.
Does anyone can suggest a good webpage or site, where I could read about how
to use IShellFolder interface in vb .net ?
E.g., I have added reference to IShellFolderEx_TLB.dll, but what...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
| |