Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

IShellFolder (Interfaces)
 
.
Summary
The IShellFolder interface is used to manage folders. It is exposed by all Shell namespace folders objects.

C# Definition:

[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("000214E6-0000-0000-C000-000000000046")]
interface IShellFolder
{
// Translates a file object's or folder's display name into an item
// identifier list.
// Return value: error code, if any
[PreserveSig()]
uint ParseDisplayName(
    IntPtr hwnd,        // Optional window handle
    IntPtr pbc,         // Optional bind context that controls the
                // parsing operation. This parameter is
                // normally set to NULL.
    [In(), MarshalAs(UnmanagedType.LPWStr)]
    string pszDisplayName,  // Null-terminated UNICODE string with the
                // display name.
    out uint pchEaten,      // Pointer to a ULONG value that receives the
                // number of characters of the
                // display name that was parsed.
    out IntPtr ppidl,       // Pointer to an ITEMIDLIST pointer that receives
                // the item identifier list for
                // the object.
    ref uint pdwAttributes); // Optional parameter that can be used to
                // query for file attributes.
                // this can be values from the SFGAO enum

// Allows a client to determine the contents of a folder by creating
// an item identifier enumeration object and returning its
// IEnumIDList interface.
// Return value: error code, if any
[PreserveSig()]
uint EnumObjects(
    IntPtr hwnd,        // If user input is required to perform the
                // enumeration, this window handle
                // should be used by the enumeration object as
                // the parent window to take
                // user input.
    SHCONTF grfFlags,       // Flags indicating which items to include in the
                // enumeration. For a list
                // of possible values, see the SHCONTF enum.
    out IEnumIDList ppenumIDList);  // Address that receives a pointer to the
                // IEnumIDList interface of the
               // enumeration object created by this method.

/// <summary>
// Retrieves an IShellFolder object for a subfolder.
// Return value: error code, if any
[PreserveSig()]
uint BindToObject(
    IntPtr pidl,        // Address of an ITEMIDLIST structure (PIDL)
                // that identifies the subfolder.
    IntPtr pbc,         // Optional address of an IBindCtx interface on
                // a bind context object to be
               // used during this operation.
    [In()]
    ref Guid riid,      // Identifier of the interface to return.
    //[MarshalAs(UnmanagedType.Interface)]
    out IntPtr ppv);    // Address that receives the interface pointer.

// Requests a pointer to an object's storage interface.
// Return value: error code, if any
[PreserveSig()]
uint BindToStorage(
    IntPtr pidl,        // Address of an ITEMIDLIST structure that
                // identifies the subfolder relative
                // to its parent folder.
    IntPtr pbc,         // Optional address of an IBindCtx interface on a
                // bind context object to be
                // used during this operation.
    [In()]
    ref Guid riid,      // Interface identifier (IID) of the requested
                // storage interface.
    [MarshalAs(UnmanagedType.Interface)]
    out object ppv);    // Address that receives the interface pointer
                // specified by riid.

// Determines the relative order of two file objects or folders, given
// their item identifier lists. Return value: If this method is
// successful, the CODE field of the HRESULT contains one of the
// following values (the code can be retrived using the helper function
// GetHResultCode): Negative A
// negative return value indicates that the first item should precede
// the second (pidl1 < pidl2).

// Positive A positive return value indicates that the first item should
// follow the second (pidl1 > pidl2).  Zero A return value of zero
// indicates that the two items are the same (pidl1 = pidl2).
[PreserveSig()]
int CompareIDs(
    int lParam,         // Value that specifies how the comparison
                // should be performed. The lower
                // Sixteen bits of lParam define the sorting
                // rule.
                // The upper sixteen bits of
                // lParam are used for flags that modify the
                // sorting rule. values can be from
                // the SHCIDS enum
    IntPtr pidl1,       // Pointer to the first item's ITEMIDLIST
                // structure.
    IntPtr pidl2);      // Pointer to the second item's ITEMIDLIST
            // structure.

// Requests an object that can be used to obtain information from or interact
// with a folder object.
// Return value: error code, if any
[PreserveSig()]
uint CreateViewObject(
    IntPtr hwndOwner,       // Handle to the owner window.
    [In()]
    ref Guid riid,      // Identifier of the requested interface.
    [MarshalAs(UnmanagedType.Interface)]
    out object ppv);    // Address of a pointer to the requested
            // interface.

// Retrieves the attributes of one or more file objects or subfolders.
// Return value: error code, if any
[PreserveSig()]
uint GetAttributesOf(
    int cidl,           // Number of file objects from which to retrieve
                // attributes.
    [In(), MarshalAs(UnmanagedType.LPArray)] IntPtr[]
    apidl,          // Address of an array of pointers to ITEMIDLIST
                // structures, each of which
                // uniquely identifies a file object relative to
                // the parent folder.
    [MarshalAs(UnmanagedType.LPArray)] SFGAOF[]
    rgfInOut);          // Address of a single ULONG value that, on
             // entry,
                // contains the attributes that the caller is
                // requesting. On exit, this value contains the
                // requested attributes that are common to all
                // of the specified objects. this value can
                // be from the SFGAO enum

// Retrieves an OLE interface that can be used to carry out actions on the
// specified file objects or folders. Return value: error code, if any
[PreserveSig()]
uint GetUIObjectOf(
    IntPtr hwndOwner,       // Handle to the owner window that the client
                // should specify if it displays
                // a dialog box or message box.
    int cidl,           // Number of file objects or subfolders specified
                // in the apidl parameter.
    [In(), MarshalAs(UnmanagedType.LPArray)] IntPtr[]
    apidl,          // Address of an array of pointers to ITEMIDLIST
                // structures, each of which
                // uniquely identifies a file object or subfolder
                // relative to the parent folder.
    [In()]
    ref Guid riid,      // Identifier of the COM interface object to
            // return.
    IntPtr rgfReserved,     // Reserved.
    [MarshalAs(UnmanagedType.Interface)]
     out object ppv);    // Pointer to the requested interface.

// Retrieves the display name for the specified file object or subfolder.
// Return value: error code, if any
[PreserveSig()]
uint GetDisplayNameOf(
    IntPtr pidl,        // Address of an ITEMIDLIST structure (PIDL)
                // that uniquely identifies the file
                // object or subfolder relative to the parent
                // folder.
    SHGNO uFlags,       // Flags used to request the type of display name
                // to return. For a list of possible values.
    out STRRET pName);      // Address of a STRRET structure in which to
                // return the display name.

// Sets the display name of a file object or subfolder, changing the item
// identifier in the process.
// Return value: error code, if any
[PreserveSig()]
uint SetNameOf(
    IntPtr hwnd,        // Handle to the owner window of any dialog or
                // message boxes that the client
                // displays.
    IntPtr pidl,        // Pointer to an ITEMIDLIST structure that
                // uniquely
                // identifies the file object
                // or subfolder relative to the parent folder.
    [In(), MarshalAs(UnmanagedType.LPWStr)]
    string pszName,     // Pointer to a null-terminated string that
                // specifies the new display name.
    SHGNO uFlags,       // Flags indicating the type of name specified by
                // the lpszName parameter. For a list of possible
                // values, see the description of the SHGNO
                // enum.
    out IntPtr ppidlOut);   // Address of a pointer to an ITEMIDLIST
                // structure
                // which receives the new ITEMIDLIST.
}

VB Definition:

  Public Shared IID_IShellDetails As New Guid("{000214EC-0000-0000-C000-000000000046}"

  <ComImportAttribute(), _
    InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown), _
    Guid("000214E6-0000-0000-C000-000000000046")> _
    Public Interface IShellFolder
    <PreserveSig()> _
    Function ParseDisplayName( _
        ByVal hwndOwner As System.IntPtr, _
        ByVal pbcReserved As System.IntPtr, _
        <MarshalAs(UnmanagedType.LPWStr)> _
        ByVal lpszDisplayName As String, _
        ByRef pchEaten As Integer, _
        ByRef ppidl As System.IntPtr, _
        ByRef pdwAttributes As Integer) As Integer

    <PreserveSig()> _
    Function EnumObjects( _
        ByVal hwndOwner As System.IntPtr, _
        <MarshalAs(UnmanagedType.U4)> ByVal _
        grfFlags As SHCONTF, _
        ByRef ppenumIDList As IEnumIDList) As Integer

    <PreserveSig()> _
    Function BindToObject( _
        ByVal pidl As System.IntPtr, _
        ByVal pbcReserved As System.IntPtr, _
        ByRef riid As Guid, _
        ByRef ppvOut As IShellFolder) As Integer

    <PreserveSig()> _
    Function BindToStorage( _
        ByRef pidl As System.IntPtr, _
        ByVal pbcReserved As System.IntPtr, _
        ByRef riid As Guid, _
        ByVal ppvObj As System.IntPtr) As Integer

    <PreserveSig()> _
    Function CompareIDs( _
        ByVal lParam As Int32, _
        ByVal pidl1 As System.IntPtr, _
        ByVal pidl2 As System.IntPtr) As Integer

    <PreserveSig()> _
    Function CreateViewObject( _
        ByVal hwndOwner As IntPtr, _
        ByVal riid As Guid, _
        ByVal ppvOut As IUnknown) As Integer

    <PreserveSig()> _
    Function GetAttributesOf( _
        ByVal cidl As Integer, _
        ByRef pidl As System.IntPtr, _
        ByRef rgfInOut As SFGAO) As Integer

    <PreserveSig()> _
        Function GetUIObjectOf( _
        ByVal hwndOwner As System.IntPtr, _
        ByVal cidl As Integer, _
        ByRef apidl As IntPtr, _
        ByRef riid As Guid, _
        ByRef prgfInOut As Integer, _
        ByRef ppvOut As IContextMenu) As Integer

    <PreserveSig()> _
    Function GetDisplayNameOf( _
        ByVal pidl As System.IntPtr, _
        <MarshalAs(UnmanagedType.U4)> _
        ByVal uFlags As SHGDN, _
        ByVal lpName As IntPtr) As Integer

    <PreserveSig()> _
    Function SetNameOf( _
        ByVal hwndOwner As System.IntPtr, _
        ByRef pidl As System.IntPtr, _
        <MarshalAs(UnmanagedType.LPWStr)> _
        ByVal lpszName As String, _
        <MarshalAs(UnmanagedType.U4)> _
        ByVal uFlags As SHCONTF, _
        ByRef ppidlOut As System.IntPtr) As Integer
    End Interface

User-Defined Types:

None.

Notes:

None.

Documentation

Notes:

I use this code a lot.

I can't read the previous version.

Too verbose.

//

// modified from Arik Poznanski

//

using System;

using System.Runtime.InteropServices;

namespace splitter7

{

    /// <summary>
    ///  managed equivalent of IShellFolder interface
    ///  Pinvoke.net / Mod by Arik Poznanski - pooya parsa
    ///  Msdn:      http://msdn.microsoft.com/en-us/library/windows/desktop/bb775075(v=vs.85).aspx
    ///  Pinvoke:   http://pinvoke.net/default.aspx/Interfaces/IShellFolder.html
    /// </summary>
    [ComImport]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("000214E6-0000-0000-C000-000000000046")]
    public interface IShellFolder
    public interface IShellFolder
    {
    /// <summary>
    /// Translates a file object's or folder's display name into an item identifier list.
    /// Return value: error code, if any
    /// </summary>
    /// <param name="hwnd">Optional window handle</param>
    /// <param name="pbc">Optional bind context that controls the parsing operation. This parameter is normally set to NULL. </param>
    /// <param name="pszDisplayName">Null-terminated UNICODE string with the display name</param>
    /// <param name="pchEaten">Pointer to a ULONG value that receives the number of characters of the display name that was parsed.</param>
    /// <param name="ppidl"> Pointer to an ITEMIDLIST pointer that receives the item identifier list for the object.</param>
    /// <param name="pdwAttributes">Optional parameter that can be used to query for file attributes.this can be values from the SFGAO enum</param>
    void ParseDisplayName(IntPtr hwnd, IntPtr pbc, String pszDisplayName, UInt32 pchEaten, out IntPtr ppidl, UInt32 pdwAttributes);
    void ParseDisplayName(
        IntPtr hwnd,
        IntPtr pbc,    
        String pszDisplayName,
        UInt32 pchEaten,
        out IntPtr ppidl,    
        UInt32 pdwAttributes);    

    void EnumObjects(
        IntPtr hwnd,
        ESHCONTF grfFlags,
        out IntPtr ppenumIDList);    

    void BindToObject(
        IntPtr pidl,        
        IntPtr pbc,        
        [In] ref Guid riid,        
        out IntPtr ppv);    

    void BindToStorage(
        IntPtr pidl,
        IntPtr pbc,    
        [In] ref Guid riid,        
        out IntPtr ppv);    

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

    void CreateViewObject(
        IntPtr hwndOwner,    
        [In] ref Guid riid,        
        out IntPtr ppv);    

    /// <summary>
    ///Allows a client to determine the contents of a folder by creating an item identifier enumeration object and returning its IEnumIDList interface.
    ///Return value: error code, if any
    /// </summary>
    /// <param name="hwnd">If user input is required to perform the enumeration, this window handle should be used by the enumeration object as the parent window to take user input.</param>
    /// <param name="grfFlags">Flags indicating which items to include in the  enumeration. For a list of possible values, see the SHCONTF enum. </param>
    /// <param name="ppenumIDList">Address that receives a pointer to the IEnumIDList interface of the enumeration object created by this method. </param>
    void EnumObjects(IntPtr hwnd, ESHCONTF grfFlags, out IntPtr ppenumIDList);
    /*      this version is good if cidl is one
* void GetAttributesOf(             UInt32 cidl,
            ref IntPtr apidl,
            ref ESFGAO rgfInOut);
*/
    void GetAttributesOf(
        UInt32 cidl,
        [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)]
        IntPtr[] apidl,
        ref ESFGAO rgfInOut);

    void GetUIObjectOf(
        IntPtr hwndOwner,
        UInt32 cidl,    // number of IntPtr's in incoming array
        [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)]
        IntPtr[] apidl,
        [In] ref Guid riid,
        UInt32 rgfReserved,
        out IntPtr ppv);

    /*    this version is good if cidl is one
          void GetUIObjectOf(
          IntPtr hwndOwner,
          UInt32 cidl,
          ref    IntPtr apidl,
          [In] ref Guid riid,
          UInt32 rgfReserved,
          out IntPtr ppv);
       */

    void GetDisplayNameOf(
        IntPtr pidl,
        ESHGDN uFlags,
        out STRRET pName);

    void SetNameOf(
        IntPtr hwnd,    
        IntPtr pidl,    
        String pszName,    
        ESHCONTF uFlags,    
        out IntPtr ppidlOut);    
    }

    /// <summary>
    ///Retrieves an IShellFolder object for a subfolder.
    // Return value: error code, if any
    /// </summary>
    /// <param name="pidl">Address of an ITEMIDLIST structure (PIDL) that identifies the subfolder.</param>
    /// <param name="pbc">Optional address of an IBindCtx interface on a bind context object to be used during this operation.</param>
    /// <param name="riid">Identifier of the interface to return. </param>
    /// <param name="ppv">Address that receives the interface pointer.</param>
    void BindToObject(IntPtr pidl, IntPtr pbc, [In]ref Guid riid, out IntPtr ppv);
    // from ShObjIdl.h
    public enum ESFGAO : uint
    {
    SFGAO_CANCOPY     =  0x00000001,
    SFGAO_CANMOVE     =  0x00000002,
    SFGAO_CANLINK     =  0x00000004,
    SFGAO_LINK        =  0x00010000,
    SFGAO_SHARE       =  0x00020000,
    SFGAO_READONLY    =  0x00040000,
    SFGAO_HIDDEN      =  0x00080000,
    SFGAO_FOLDER      =  0x20000000,
    SFGAO_FILESYSTEM      =  0x40000000,
    SFGAO_HASSUBFOLDER    =  0x80000000,
    }

    public enum ESHCONTF
    {
    SHCONTF_FOLDERS = 0x0020,
    SHCONTF_NONFOLDERS = 0x0040,
    SHCONTF_INCLUDEHIDDEN = 0x0080,
    SHCONTF_INIT_ON_FIRST_NEXT = 0x0100,
    SHCONTF_NETPRINTERSRCH  = 0x0200,
    SHCONTF_SHAREABLE = 0x0400,
    SHCONTF_STORAGE = 0x0800  
    }
      // from shlobj.h
    public enum ESHGDN
    {
    SHGDN_NORMAL         = 0x0000,
    SHGDN_INFOLDER       = 0x0001,
    SHGDN_FOREDITING     = 0x1000,
    SHGDN_FORADDRESSBAR    = 0x4000,
    SHGDN_FORPARSING     = 0x8000,
    }

    public  enum ESTRRET : int
    {
    eeRRET_WSTR     = 0x0000,            // Use STRRET.pOleStr
    STRRET_OFFSET   = 0x0001,    // Use STRRET.uOffset to Ansi
    STRRET_CSTR     = 0x0002            // Use STRRET.cStr
    }

    /*
    // Microsoft's sample and it works too.
    see sample,    Unions.cs

    /// <summary>
    /// Requests a pointer to an object's storage interface.
    /// Return value: error code, if any
    /// </summary>
    /// <param name="pidl">Address of an ITEMIDLIST structure that identifies the subfolder relative to its parent folder. </param>
    /// <param name="pbc">Optional address of an IBindCtx interface on a bind context object to be  used during this operation.</param>
    /// <param name="riid">Interface identifier (IID) of the requested storage interface.</param>
    /// <param name="ppv"> Address that receives the interface pointer specified by riid.</param>
    void BindToStorage(IntPtr pidl, IntPtr pbc, [In]ref Guid riid, out IntPtr ppv);
    union MYUNION2
    {
    int i;
    char str[128];
    };


    [ StructLayout( LayoutKind.Explicit, Size=128 )]
    public struct MyUnion2_1
    {
    [ FieldOffset( 0 )]
    public int i;
    }
    */
    // shlobj.h

    // this works too...from Unions.cs
    [StructLayout(LayoutKind.Explicit, Size=520)]
    public struct STRRETinternal
    {
    [FieldOffset(0)]
    public IntPtr pOleStr;

    /// <summary>
    /// Determines the relative order of two file objects or folders, given
    /// their item identifier lists. Return value: If this method is
    /// successful, the CODE field of the HRESULT contains one of the
    /// following values (the code can be retrived using the helper function
    /// GetHResultCode): Negative A negative return value indicates that the first item should precede the second (pidl1 < pidl2).
    ////
    ///Positive A positive return value indicates that the first item should
    ///follow the second (pidl1 > pidl2).  Zero A return value of zero
    ///indicates that the two items are the same (pidl1 = pidl2).
    /// </summary>
    /// <param name="lParam">Value that specifies how the comparison  should be performed. The lower Sixteen bits of lParam define the sorting  rule.
    ///  The upper sixteen bits of lParam are used for flags that modify the sorting rule. values can be from  the SHCIDS enum
    /// </param>
    /// <param name="pidl1">Pointer to the first item's ITEMIDLIST structure.</param>
    /// <param name="pidl2"> Pointer to the second item's ITEMIDLIST structure.</param>
    /// <returns></returns>
    [PreserveSig]Int32 CompareIDs(Int32 lParam, IntPtr pidl1, IntPtr pidl2);
    [FieldOffset(0)]
    public IntPtr pStr;  // LPSTR pStr;   NOT USED

    [FieldOffset(0)]
    public uint  uOffset;

    }

    [StructLayout(LayoutKind.Sequential )]
    public struct STRRET
    {
    public uint uType;
    public STRRETinternal data;
    }

    /// <summary>
    /// Requests an object that can be used to obtain information from or interact
    /// with a folder object.
    /// Return value: error code, if any
    /// </summary>
    /// <param name="hwndOwner">Handle to the owner window.</param>
    /// <param name="riid">Identifier of the requested interface.</param>
    /// <param name="ppv">Address of a pointer to the requested interface. </param>
    void CreateViewObject(IntPtr hwndOwner, [In] ref Guid riid, out IntPtr ppv);
    public class Guid_IShellFolder
    {
    public static Guid IID_IShellFolder =
        new Guid("{000214E6-0000-0000-C000-000000000046}");
    }

}

    /// <summary>
    /// Retrieves the attributes of one or more file objects or subfolders.
    /// Return value: error code, if any
    /// </summary>
    /// <param name="cidl">Number of file objects from which to retrieve attributes. </param>
    /// <param name="apidl">Address of an array of pointers to ITEMIDLIST structures, each of which  uniquely identifies a file object relative to the parent folder.</param>
    /// <param name="rgfInOut">Address of a single ULONG value that, on entry contains the attributes that the caller is
    /// requesting. On exit, this value contains the requested attributes that are common to all of the specified objects. this value can be from the SFGAO enum
    /// </param>
    void GetAttributesOf(UInt32 cidl, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]IntPtr[] apidl, ref ESFGAO rgfInOut);



    /// <summary>
    /// Retrieves an OLE interface that can be used to carry out actions on the
    /// specified file objects or folders. Return value: error code, if any
    /// </summary>
    /// <param name="hwndOwner">Handle to the owner window that the client should specify if it displays a dialog box or message box.</param>
    /// <param name="cidl">Number of file objects or subfolders specified in the apidl parameter. </param>
    /// <param name="apidl">Address of an array of pointers to ITEMIDLIST  structures, each of which  uniquely identifies a file object or subfolder relative to the parent folder.</param>
    /// <param name="riid">Identifier of the COM interface object to return.</param>
    /// <param name="rgfReserved"> Reserved. </param>
    /// <param name="ppv">Pointer to the requested interface.</param>
    void GetUIObjectOf(IntPtr hwndOwner, UInt32 cidl, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]IntPtr[] apidl, [In] ref Guid riid, UInt32 rgfReserved, out IntPtr ppv);



    /// <summary>
    /// Retrieves the display name for the specified file object or subfolder.
    /// Return value: error code, if any
    /// </summary>
    /// <param name="pidl">Address of an ITEMIDLIST structure (PIDL)  that uniquely identifies the file  object or subfolder relative to the parent  folder. </param>
    /// <param name="uFlags">Flags used to request the type of display name to return. For a list of possible values. </param>
    /// <param name="pName"> Address of a STRRET structure in which to return the display name.</param>
    void GetDisplayNameOf(IntPtr pidl, ESHGDN uFlags, out STRRET pName);



    /// <summary>
    /// Sets the display name of a file object or subfolder, changing the item
    /// identifier in the process.
    /// Return value: error code, if any
    /// </summary>
    /// <param name="hwnd"> Handle to the owner window of any dialog or message boxes that the client displays.</param>
    /// <param name="pidl"> Pointer to an ITEMIDLIST structure that uniquely identifies the file object or subfolder relative to the parent folder. </param>
    /// <param name="pszName"> Pointer to a null-terminated string that specifies the new display name.</param>
    /// <param name="uFlags">Flags indicating the type of name specified by  the lpszName parameter. For a list of possible values, see the description of the SHGNO enum.</param>
    /// <param name="ppidlOut"></param>
    void SetNameOf(IntPtr hwnd, IntPtr pidl, String pszName, ESHCONTF uFlags, out IntPtr ppidlOut);


    }

    public enum ESFGAO : uint
    {
    SFGAO_CANCOPY = 0x00000001,
    SFGAO_CANMOVE = 0x00000002,
    SFGAO_CANLINK = 0x00000004,
    SFGAO_LINK = 0x00010000,
    SFGAO_SHARE = 0x00020000,
    SFGAO_READONLY = 0x00040000,
    SFGAO_HIDDEN = 0x00080000,
    SFGAO_FOLDER = 0x20000000,
    SFGAO_FILESYSTEM = 0x40000000,
    SFGAO_HASSUBFOLDER = 0x80000000,
    }

    public enum ESHCONTF
    {
    SHCONTF_FOLDERS = 0x0020,
    SHCONTF_NONFOLDERS = 0x0040,
    SHCONTF_INCLUDEHIDDEN = 0x0080,
    SHCONTF_INIT_ON_FIRST_NEXT = 0x0100,
    SHCONTF_NETPRINTERSRCH = 0x0200,
    SHCONTF_SHAREABLE = 0x0400,
    SHCONTF_STORAGE = 0x0800
    }

    public enum ESHGDN
    {
    SHGDN_NORMAL = 0x0000,
    SHGDN_INFOLDER = 0x0001,
    SHGDN_FOREDITING = 0x1000,
    SHGDN_FORADDRESSBAR = 0x4000,
    SHGDN_FORPARSING = 0x8000,
    }

    public enum ESTRRET : int
    {
    eeRRET_WSTR = 0x0000,    // Use STRRET.pOleStr
    STRRET_OFFSET = 0x0001,    // Use STRRET.uOffset to Ansi
    STRRET_CSTR = 0x0002    // Use STRRET.cStr
    }



    // this works too...from Unions.cs
    [StructLayout(LayoutKind.Explicit, Size = 520)]
    public struct STRRETinternal
    {
    [FieldOffset(0)]
    public IntPtr pOleStr;

    [FieldOffset(0)]
    public IntPtr pStr;  // LPSTR pStr;   NOT USED

    [FieldOffset(0)]
    public uint uOffset;

    }

    [StructLayout(LayoutKind.Sequential)]
    public struct STRRET
    {
    public uint uType;
    public STRRETinternal data;
    }

    public class Guid_IShellFolder
    {
    public static Guid IID_IShellFolder = new Guid("{000214E6-0000-0000-C000-000000000046}");
    }


}

VB Definition:

    <ComImport(),
    Guid("000214E6-0000-0000-C000-000000000046"),
    InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
    Private Interface IShellFolder
        Sub ParseDisplayName(hWnd As IntPtr, pbc As IntPtr, pszDisplayName As String, ByRef pchEaten As Integer, ByRef ppidl As System.IntPtr, ByRef pdwAttributes As Integer)
        Sub EnumObjects(hwndOwner As IntPtr, <MarshalAs(UnmanagedType.U4)> grfFlags As Integer, <Out()> ByRef ppenumIDList As IntPtr)
        Sub BindToObject(pidl As IntPtr, pbcReserved As IntPtr, ByRef riid As Guid, ByRef ppvOut As IShellFolder)
        Sub BindToStorage(pidl As IntPtr, pbcReserved As IntPtr, ByRef riid As Guid, <Out()> ppvObj As IntPtr)
        <PreserveSig()>
        Function CompareIDs(lParam As IntPtr, pidl1 As IntPtr, pidl2 As IntPtr) As Integer
        Sub CreateViewObject(hwndOwner As IntPtr, ByRef riid As Guid, ppvOut As Object)
        Sub GetAttributesOf(cidl As Integer, apidl As IntPtr, <MarshalAs(UnmanagedType.U4)> ByRef rgfInOut As Integer)
        Sub GetUIObjectOf(hwndOwner As IntPtr, cidl As Integer, ByRef apidl As IntPtr, ByRef riid As Guid, <Out()> prgfInOut As Integer, <Out(), MarshalAs(UnmanagedType.IUnknown)> ByRef ppvOut As Object)
        Sub GetDisplayNameOf(pidl As IntPtr, <MarshalAs(UnmanagedType.U4)> uFlags As Integer, ByRef lpName As STRRET_CSTR)
        Sub SetNameOf(hwndOwner As IntPtr, pidl As IntPtr, <MarshalAs(UnmanagedType.LPWStr)> lpszName As String, <MarshalAs(UnmanagedType.U4)> uFlags As Integer, ByRef ppidlOut As IntPtr)
    End Interface

    <StructLayout(LayoutKind.Sequential)>
    Private Structure STRRET_CSTR
        Public uType As Integer
        <FieldOffset(4), MarshalAs(UnmanagedType.LPWStr)>
        Public pOleStr As String
        <FieldOffset(4)>
        Public uOffset As Integer
        <FieldOffset(4), MarshalAs(UnmanagedType.ByValArray, SizeConst:=520)>
        Public strName As Byte()
    End Structure

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions