473,472 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Implementing an IShellFolder interface?

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 references.

I've seen a C# version of how to do it, but I have no idea how to translate
this into VB :-0.
(C# version below, no idea if it works or not!)

using System.Runtime.InteropServices;

[Flags()]
enum SHCONTF
{
SHCONTF_FOLDERS = 0x20,
SHCONTF_NONFOLDERS = 0x40,
SHCONTF_INCLUDEHIDDEN = 0x80,
SHCONTF_INIT_ON_FIRST_NEXT = 0x100,
SHCONTF_NETPRINTERSRCH = 0x200,
SHCONTF_SHAREABLE = 0x400,
SHCONTF_STORAGE = 0x800
}

[Flags()]
enum SFGAOF
{
SFGAO_CANCOPY = 0x1,
SFGAO_CANMOVE = 0x2,
SFGAO_CANLINK = 0x4,
SFGAO_STORAGE = 0x8,
SFGAO_CANRENAME = 0x10,
SFGAO_CANDELETE = 0x20,
SFGAO_HASPROPSHEET = 0x40,
SFGAO_DROPTARGET = 0x100,
SFGAO_CAPABILITYMASK = 0x177,
SFGAO_ENCRYPTED = 0x2000,
SFGAO_ISSLOW = 0x4000,
SFGAO_GHOSTED = 0x8000,
SFGAO_LINK = 0x10000,
SFGAO_SHARE = 0x20000,
SFGAO_READONLY = 0x40000,
SFGAO_HIDDEN = 0x80000,
SFGAO_DISPLAYATTRMASK = 0xFC000,
SFGAO_FILESYSANCESTOR = 0x10000000,
SFGAO_FOLDER = 0x20000000,
SFGAO_FILESYSTEM = 0x40000000,
SFGAO_HASSUBFOLDER = unchecked( (int) 0x80000000 ),
SFGAO_CONTENTSMASK = unchecked( (int) 0x80000000 ),
SFGAO_VALIDATE = 0x1000000,
SFGAO_REMOVABLE = 0x2000000,
SFGAO_COMPRESSED = 0x4000000,
SFGAO_BROWSABLE = 0x8000000,
SFGAO_NONENUMERATED = 0x100000,
SFGAO_NEWCONTENT = 0x200000,
SFGAO_CANMONIKER = 0x400000,
SFGAO_HASSTORAGE = 0x400000,
SFGAO_STREAM = 0x400000,
SFGAO_STORAGEANCESTOR = 0x800000,
SFGAO_STORAGECAPMASK = 0x70C50008
}

[Flags()]
enum SHGNO
{
SHGDN_NORMAL = 0x0,
SHGDN_INFOLDER = 0x1,
SHGDN_FOREDITING = 0x1000,
SHGDN_FORADDRESSBAR = 0x4000,
SHGDN_FORPARSING = 0x8000,
}

[StructLayout(LayoutKind.Sequential)]
struct STRRET
{
int uType;
/*
IntPtr pOleStr;
uint uOffset;
*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst=260)] byte[] cStr;
}

[
ComImport(),
Guid("000214E6-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )
]
interface IShellFolder
{
[PreserveSig()]
uint ParseDisplayName(
IntPtr hwnd,
IntPtr pbc,
[In(), MarshalAs(UnmanagedType.LPWStr)] string pszDisplayName,
out uint pchEaten,
out IntPtr ppidl,
ref uint pdwAttributes);

[PreserveSig()]
uint EnumObjects(
IntPtr hwnd,
SHCONTF grfFlags,
out IEnumIDList ppenumIDList);

[PreserveSig()]
uint BindToObject(
IntPtr pidl,
IntPtr pbc,
[In()] ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out object ppv);

[PreserveSig()]
uint BindToStorage(
IntPtr pidl,
IntPtr pbc,
[In()] ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out object ppv);

[PreserveSig()]
uint CompareIDs(
int lParam,
IntPtr pidl1,
IntPtr pidl2);

[PreserveSig()]
uint CreateViewObject(
IntPtr hwndOwner,
[In()] ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out object ppv);

[PreserveSig()]
uint GetAttributesOf(
int cidl,
[In(), MarshalAs(UnmanagedType.LPArray)] IntPtr[] apidl,
[MarshalAs(UnmanagedType.LPArray)] SFGAOF[] rgfInOut);

[PreserveSig()]
uint GetUIObjectOf(
IntPtr hwndOwner,
int cidl,
[In(), MarshalAs(UnmanagedType.LPArray)] IntPtr[] apidl,
[In()] ref Guid riid,
IntPtr rgfReserved,
[MarshalAs(UnmanagedType.Interface)] out object ppv);

[PreserveSig()]
uint GetDisplayNameOf(
IntPtr pidl,
SHGNO uFlags,
out STRRET pName);

[PreserveSig()]
uint SetNameOf(
IntPtr hwnd,
IntPtr pidl,
[In(), MarshalAs(UnmanagedType.LPWStr)] string pszName,
SHGNO uFlags,
out IntPtr ppidlOut);
}

[
ComImport(),
Guid("000214F2-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )
]
interface IEnumIDList {

[PreserveSig()]
uint Next(
int celt,
[MarshalAs(UnmanagedType.LPArray)] IntPtr[] rgelt,
out int pceltFetched);

void Skip(
int celt);

void Reset();

void Clone(
out IEnumIDList ppenum);
}
Nov 20 '05 #1
0 1405

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...
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...
2
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...
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: 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...
6
by: Raj Wall | last post by:
Hi, I am trying to implement the IEqualityComparer interface for a struct so I can use it as the Key for a Dictionary. My struct declaration has: public struct Ring : IEqualityComparer {...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.