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

How to define iShellFolder in VB.NET?

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


Nov 20 '05 #1
2 6122
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
"Nicola Garone" <ng*****@dimensionecad.it> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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

Nov 20 '05 #2
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
"Nicola Garone" <ng*****@dimensionecad.it> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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

Nov 20 '05 #3

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

Similar topics

2
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...
0
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...
4
by: Robin Tucker | last post by:
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...
2
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...
4
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...
1
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...
1
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...
1
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...
2
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...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.