473,382 Members | 1,367 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,382 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 6120
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.