How to define iShellFolder in VB.NET?

N

Nicola Garone

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 Shell32.dll, but I can't find any
definition of iShellFolder under new Shell32 namespace.

Must I define the interface manually? Should I use a module within interface
definition:

Interface iShellFolder
Function ParseDisplayName(ByVal IntPtr As Long, bla bla bla ) as
long
Function...
End Interface

or should I use tlbimport, edit it manually (how?) and... what?

I've read a lot of documents but I can't find a complete walktrough, can
someone help me please?

Thanks in advance.
Nicola
 
R

Robin Tucker

Yes, you need to do this yourself. Here is my version. I hasn't been fully
tested but seems to work for the bits I use ;). Note that you will need to
define SHCONTF and STRRET (can be found in MSDN) and modify parameters as
required.

' /////////////////////////////////////////////////////////////////////////
' //
' // IShellFolder
' //
' /////////////////////////////////////////////////////////////////////////

<ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("000214E6-0000-0000-C000-000000000046")> _
Public Interface IShellFolder

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function ParseDisplayName(ByVal hwnd As IntPtr, ByVal pbc As IntPtr,
<MarshalAs(UnmanagedType.LPWStr)> ByVal pszDisplayName As String, ByRef
pchEaten As Integer, ByRef ppidl As IntPtr, ByRef pdwAttributes As Integer)
As Integer

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function EnumObjects(ByVal hwnd As IntPtr, ByVal grfFlags As
COM.ShellAPI.SHCONTF, ByRef ppenumIDList As IntPtr) As Int32

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function BindToObject(ByVal pidl As IntPtr, ByVal pbc As IntPtr, ByRef
riid As Guid, ByRef ppv As IntPtr) As Int32

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function BindToStorage(ByVal pidl As IntPtr, ByVal pbc As IntPtr, ByRef
riid As Guid, ByRef ppv As IntPtr) As Int32

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function CompareIDs(ByVal lParam As Int32, ByVal pidl1 As IntPtr, ByVal
pidl2 As IntPtr) As Int32

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function CreateViewObject(ByVal hwndOwner As IntPtr, ByVal riid As Guid,
ByRef ppv As IntPtr) As Int32

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function GetAttributesOf(ByVal cidl As Integer, ByRef apidl As IntPtr,
ByRef rgfInOut As Integer) As Integer

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function GetUIObjectOf(ByVal hwndOwner As IntPtr, ByVal cidl As UInt32,
ByVal apidl() As IntPtr, ByVal riid As Guid, ByRef rgfReserved As UInt32,
ByRef ppv As IntPtr) As Int32

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function GetDisplayNameOf(ByVal pidl As IntPtr, ByVal uFlags As Integer,
ByRef pName As COM.ShellAPI.STRRET) As Int32

'
/////////////////////////////////////////////////////////////////////////
' //
'
/////////////////////////////////////////////////////////////////////////
<PreserveSig()> _
Function SetNameOf(ByVal hwnd As IntPtr, ByVal pidl As IntPtr,
<MarshalAs(UnmanagedType.LPWStr)> ByVal pszName As [String], ByVal uFlags As
UInt32, ByRef ppidlOut As IntPtr) As Int32
End Interface
 

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