Advertisement
ZelAnton

Shell32

Sep 29th, 2015
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 29.87 KB | None | 0 0
  1. public static class Shell32
  2. {
  3.     public static Type ShellFolderType = typeof(IShellFolder);
  4.     public static Type EnumIDListType = typeof(IEnumIDList);
  5.     public static Guid IID_IShellFolder = new Guid("{000214E6-0000-0000-C000-000000000046}");
  6.  
  7.     // Retrieves the path of a folder as an PIDL.
  8.     [DllImport("shell32.dll")]
  9.     public static extern Int32 SHGetFolderLocation(
  10.         IntPtr hwndOwner,       // Handle to the owner window.
  11.         Int32 nFolder,          // A CSIDL value that identifies the folder to be located.
  12.         IntPtr hToken,          // Token that can be used to represent a particular user.
  13.         UInt32 dwReserved,      // Reserved.
  14.         out IntPtr ppidl);      // Address of a pointer to an item identifier list structure
  15.     // specifying the folder's location relative to the root of the namespace
  16.     // (the desktop).
  17.  
  18.     [DllImport("user32.dll", CharSet = CharSet.Auto)]
  19.     public extern static bool DestroyIcon(IntPtr handle);
  20.  
  21.     // Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.
  22.     [DllImport("shell32.dll")]
  23.     public static extern Int32 SHGetDesktopFolder(
  24.         out IntPtr ppshf);          // Address that receives an IShellFolder interface pointer for the
  25.     // desktop folder.
  26.  
  27.     // Takes a STRRET structure returned by IShellFolder::GetDisplayNameOf, converts it to a string, and
  28.     // places the result in a buffer.
  29.     [DllImport("shlwapi.dll")]
  30.     public static extern Int32 StrRetToBuf(
  31.         ref STRRET pstr,        // Pointer to the STRRET structure. When the function returns, this pointer will no
  32.         // longer be valid.
  33.         IntPtr pidl,            // Pointer to the item's ITEMIDLIST structure.
  34.         StringBuilder pszBuf,   // Buffer to hold the display name. It will be returned as a null-terminated
  35.         // string. If cchBuf is too small, the name will be truncated to fit.
  36.         UInt32 cchBuf);         // Size of pszBuf, in characters. If cchBuf is too small, the string will be
  37.     // truncated to fit.
  38.  
  39.     [DllImport("shell32.dll")]
  40.     public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttribs, out SHFILEINFO psfi, uint cbFileInfo, SHGFI uFlags);
  41.  
  42.     [DllImport("shell32.dll")]
  43.     public static extern IntPtr SHGetFileInfo(IntPtr pIDL, uint dwFileAttributes, out SHFILEINFO psfi, uint cbFileInfo, SHGFI uFlags);
  44.  
  45.     [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
  46.     public struct SHFILEINFO
  47.     {
  48.         public SHFILEINFO(bool b)
  49.         {
  50.             hIcon = IntPtr.Zero;
  51.             iIcon = 0;
  52.             dwAttributes = 0;
  53.             szDisplayName = "";
  54.             szTypeName = "";
  55.         }
  56.  
  57.         /// <summary>Maximal Length of unmanaged Windows-Path-strings</summary>
  58.         private const int MAX_PATH = 260;
  59.         /// <summary>Maximal Length of unmanaged Typename</summary>
  60.         private const int MAX_TYPE = 80;
  61.  
  62.         public IntPtr hIcon;
  63.         public int iIcon;
  64.         public uint dwAttributes;
  65.         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
  66.         public string szDisplayName;
  67.         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_TYPE)]
  68.         public string szTypeName;
  69.     };
  70.  
  71.     [DllImport("shell32.dll")]
  72.     public static extern IntPtr ILCombine(IntPtr pIDLParent, IntPtr pIDLChild);
  73.  
  74.     [DllImport("shell32.dll")]
  75.     public static extern void ILFree([In] IntPtr pidl);
  76.  
  77.     public static IShellFolder GetDesktopFolder()
  78.     {
  79.         IntPtr ptrRet;
  80.         SHGetDesktopFolder(out ptrRet);
  81.  
  82.         Object obj = Marshal.GetTypedObjectForIUnknown(ptrRet, ShellFolderType);
  83.         IShellFolder ishellFolder = (IShellFolder)obj;
  84.  
  85.         return ishellFolder;
  86.     }
  87.  
  88.     /// <summary>
  89.     ///  managed equivalent of IShellFolder interface
  90.     ///  Pinvoke.net / Mod by Arik Poznanski - pooya parsa
  91.     ///  Msdn:      http://msdn.microsoft.com/en-us/library/windows/desktop/bb775075(v=vs.85).aspx
  92.     ///  Pinvoke:   http://pinvoke.net/default.aspx/Interfaces/IShellFolder.html
  93.     /// </summary>
  94.     [ComImport]
  95.     [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  96.     [Guid("000214E6-0000-0000-C000-000000000046")]
  97.     public interface IShellFolder
  98.     {
  99.         /// <summary>
  100.         /// Translates a file object's or folder's display name into an item identifier list.
  101.         /// Return value: error code, if any
  102.         /// </summary>
  103.         /// <param name="hwnd">Optional window handle</param>
  104.         /// <param name="pbc">Optional bind context that controls the parsing operation. This parameter is normally set to NULL. </param>
  105.         /// <param name="pszDisplayName">Null-terminated UNICODE string with the display name</param>
  106.         /// <param name="pchEaten">Pointer to a ULONG value that receives the number of characters of the display name that was parsed.</param>
  107.         /// <param name="ppidl"> Pointer to an ITEMIDLIST pointer that receives the item identifier list for the object.</param>
  108.         /// <param name="pdwAttributes">Optional parameter that can be used to query for file attributes.this can be values from the SFGAO enum</param>
  109.         void ParseDisplayName(IntPtr hwnd, IntPtr pbc, String pszDisplayName, UInt32 pchEaten, out IntPtr ppidl, UInt32 pdwAttributes);
  110.  
  111.         /// <summary>
  112.         ///Allows a client to determine the contents of a folder by creating an item identifier enumeration object and returning its IEnumIDList interface.
  113.         ///Return value: error code, if any
  114.         /// </summary>
  115.         /// <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>
  116.         /// <param name="grfFlags">Flags indicating which items to include in the  enumeration. For a list of possible values, see the SHCONTF enum. </param>
  117.         /// <param name="ppenumIDList">Address that receives a pointer to the IEnumIDList interface of the enumeration object created by this method. </param>
  118.         void EnumObjects(IntPtr hwnd, ESHCONTF grfFlags, out IntPtr ppenumIDList);
  119.  
  120.         /// <summary>
  121.         ///Retrieves an IShellFolder object for a subfolder.
  122.         // Return value: error code, if any
  123.         /// </summary>
  124.         /// <param name="pidl">Address of an ITEMIDLIST structure (PIDL) that identifies the subfolder.</param>
  125.         /// <param name="pbc">Optional address of an IBindCtx interface on a bind context object to be used during this operation.</param>
  126.         /// <param name="riid">Identifier of the interface to return. </param>
  127.         /// <param name="ppv">Address that receives the interface pointer.</param>
  128.         void BindToObject(IntPtr pidl, IntPtr pbc, [In]ref Guid riid, out IntPtr ppv);
  129.  
  130.         /// <summary>
  131.         /// Requests a pointer to an object's storage interface.
  132.         /// Return value: error code, if any
  133.         /// </summary>
  134.         /// <param name="pidl">Address of an ITEMIDLIST structure that identifies the subfolder relative to its parent folder. </param>
  135.         /// <param name="pbc">Optional address of an IBindCtx interface on a bind context object to be  used during this operation.</param>
  136.         /// <param name="riid">Interface identifier (IID) of the requested storage interface.</param>
  137.         /// <param name="ppv"> Address that receives the interface pointer specified by riid.</param>
  138.         void BindToStorage(IntPtr pidl, IntPtr pbc, [In]ref Guid riid, out IntPtr ppv);
  139.  
  140.         /// <summary>
  141.         /// Determines the relative order of two file objects or folders, given
  142.         /// their item identifier lists. Return value: If this method is
  143.         /// successful, the CODE field of the HRESULT contains one of the
  144.         /// following values (the code can be retrived using the helper function
  145.         /// GetHResultCode): Negative A negative return value indicates that the first item should precede the second (pidl1 < pidl2).
  146.         ////
  147.         ///Positive A positive return value indicates that the first item should
  148.         ///follow the second (pidl1 > pidl2).  Zero A return value of zero
  149.         ///indicates that the two items are the same (pidl1 = pidl2).
  150.         /// </summary>
  151.         /// <param name="lParam">Value that specifies how the comparison  should be performed. The lower Sixteen bits of lParam define the sorting  rule.
  152.         ///  The upper sixteen bits of lParam are used for flags that modify the sorting rule. values can be from  the SHCIDS enum
  153.         /// </param>
  154.         /// <param name="pidl1">Pointer to the first item's ITEMIDLIST structure.</param>
  155.         /// <param name="pidl2"> Pointer to the second item's ITEMIDLIST structure.</param>
  156.         /// <returns></returns>
  157.         [PreserveSig]
  158.         Int32 CompareIDs(Int32 lParam, IntPtr pidl1, IntPtr pidl2);
  159.  
  160.         /// <summary>
  161.         /// Requests an object that can be used to obtain information from or interact
  162.         /// with a folder object.
  163.         /// Return value: error code, if any
  164.         /// </summary>
  165.         /// <param name="hwndOwner">Handle to the owner window.</param>
  166.         /// <param name="riid">Identifier of the requested interface.</param>
  167.         /// <param name="ppv">Address of a pointer to the requested interface. </param>
  168.         void CreateViewObject(IntPtr hwndOwner, [In] ref Guid riid, out IntPtr ppv);
  169.  
  170.         /// <summary>
  171.         /// Retrieves the attributes of one or more file objects or subfolders.
  172.         /// Return value: error code, if any
  173.         /// </summary>
  174.         /// <param name="cidl">Number of file objects from which to retrieve attributes. </param>
  175.         /// <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>
  176.         /// <param name="rgfInOut">Address of a single ULONG value that, on entry contains the attributes that the caller is
  177.         /// 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
  178.         /// </param>
  179.         void GetAttributesOf(UInt32 cidl, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]IntPtr[] apidl, ref ESFGAO rgfInOut);
  180.  
  181.         /// <summary>
  182.         /// Retrieves an OLE interface that can be used to carry out actions on the
  183.         /// specified file objects or folders. Return value: error code, if any
  184.         /// </summary>
  185.         /// <param name="hwndOwner">Handle to the owner window that the client should specify if it displays a dialog box or message box.</param>
  186.         /// <param name="cidl">Number of file objects or subfolders specified in the apidl parameter. </param>
  187.         /// <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>
  188.         /// <param name="riid">Identifier of the COM interface object to return.</param>
  189.         /// <param name="rgfReserved"> Reserved. </param>
  190.         /// <param name="ppv">Pointer to the requested interface.</param>
  191.         void GetUIObjectOf(IntPtr hwndOwner, UInt32 cidl, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]IntPtr[] apidl, [In] ref Guid riid, UInt32 rgfReserved, out IntPtr ppv);
  192.  
  193.         /// <summary>
  194.         /// Retrieves the display name for the specified file object or subfolder.
  195.         /// Return value: error code, if any
  196.         /// </summary>
  197.         /// <param name="pidl">Address of an ITEMIDLIST structure (PIDL)  that uniquely identifies the file  object or subfolder relative to the parent  folder. </param>
  198.         /// <param name="uFlags">Flags used to request the type of display name to return. For a list of possible values. </param>
  199.         /// <param name="pName"> Address of a STRRET structure in which to return the display name.</param>
  200.         void GetDisplayNameOf(IntPtr pidl, ESHGDN uFlags, out STRRET pName);
  201.  
  202.         /// <summary>
  203.         /// Sets the display name of a file object or subfolder, changing the item
  204.         /// identifier in the process.
  205.         /// Return value: error code, if any
  206.         /// </summary>
  207.         /// <param name="hwnd"> Handle to the owner window of any dialog or message boxes that the client displays.</param>
  208.         /// <param name="pidl"> Pointer to an ITEMIDLIST structure that uniquely identifies the file object or subfolder relative to the parent folder. </param>
  209.         /// <param name="pszName"> Pointer to a null-terminated string that specifies the new display name.</param>
  210.         /// <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>
  211.         /// <param name="ppidlOut"></param>
  212.         void SetNameOf(IntPtr hwnd, IntPtr pidl, String pszName, ESHCONTF uFlags, out IntPtr ppidlOut);
  213.  
  214.     }
  215.  
  216.     public enum ESFGAO : uint
  217.     {
  218.         SFGAO_CANCOPY = 0x00000001,
  219.         SFGAO_CANMOVE = 0x00000002,
  220.         SFGAO_CANLINK = 0x00000004,
  221.         SFGAO_LINK = 0x00010000,
  222.         SFGAO_SHARE = 0x00020000,
  223.         SFGAO_READONLY = 0x00040000,
  224.         SFGAO_HIDDEN = 0x00080000,
  225.         SFGAO_FOLDER = 0x20000000,
  226.         SFGAO_FILESYSTEM = 0x40000000,
  227.         SFGAO_HASSUBFOLDER = 0x80000000,
  228.     }
  229.  
  230.     public enum ESHCONTF
  231.     {
  232.         SHCONTF_FOLDERS = 0x0020,
  233.         SHCONTF_NONFOLDERS = 0x0040,
  234.         SHCONTF_INCLUDEHIDDEN = 0x0080,
  235.         SHCONTF_INIT_ON_FIRST_NEXT = 0x0100,
  236.         SHCONTF_NETPRINTERSRCH = 0x0200,
  237.         SHCONTF_SHAREABLE = 0x0400,
  238.         SHCONTF_STORAGE = 0x0800
  239.     }
  240.  
  241.     public enum ESHGDN
  242.     {
  243.         SHGDN_NORMAL = 0x0000,
  244.         SHGDN_INFOLDER = 0x0001,
  245.         SHGDN_FOREDITING = 0x1000,
  246.         SHGDN_FORADDRESSBAR = 0x4000,
  247.         SHGDN_FORPARSING = 0x8000,
  248.     }
  249.  
  250.     // this works too...from Unions.cs
  251.     [StructLayout(LayoutKind.Explicit, Size = 520)]
  252.     public struct STRRETinternal
  253.     {
  254.         [FieldOffset(0)]
  255.         public IntPtr pOleStr;
  256.  
  257.         [FieldOffset(0)]
  258.         public IntPtr pStr;  // LPSTR pStr;   NOT USED
  259.  
  260.         [FieldOffset(0)]
  261.         public uint uOffset;
  262.  
  263.     }
  264.  
  265.     [StructLayout(LayoutKind.Sequential)]
  266.     public struct STRRET
  267.     {
  268.         public uint uType;
  269.         public STRRETinternal data;
  270.     }
  271.  
  272.     public enum CSIDL
  273.     {
  274.         CSIDL_FLAG_CREATE = (0x8000),   // Version 5.0. Combine this CSIDL with any of the following
  275.         //CSIDLs to force the creation of the associated folder.
  276.         CSIDL_ADMINTOOLS = (0x0030),    // Version 5.0. The file system directory that is used to store
  277.         // administrative tools for an individual user. The Microsoft
  278.         // Management Console (MMC) will save customized consoles to
  279.         // this directory, and it will roam with the user.
  280.         CSIDL_ALTSTARTUP = (0x001d),    // The file system directory that corresponds to the user's
  281.         // nonlocalized Startup program group.
  282.         CSIDL_APPDATA = (0x001a),   // Version 4.71. The file system directory that serves as a
  283.         // common repository for application-specific data. A typical
  284.         // path is C:\Documents and Settings\username\Application Data.
  285.         // This CSIDL is supported by the redistributable Shfolder.dll
  286.         // for systems that do not have the Microsoft® Internet
  287.         // Explorer 4.0 integrated Shell installed.
  288.         CSIDL_BITBUCKET = (0x000a), // The virtual folder containing the objects in the user's
  289.         // Recycle Bin.
  290.         CSIDL_CDBURN_AREA = (0x003b),   // Version 6.0. The file system directory acting as a staging
  291.         // area for files waiting to be written to CD. A typical path
  292.         // is C:\Documents and Settings\username\Local Settings\
  293.         // Application Data\Microsoft\CD Burning.
  294.         CSIDL_COMMON_ADMINTOOLS = (0x002f), // Version 5.0. The file system directory containing
  295.         // administrative tools for all users of the computer.
  296.         CSIDL_COMMON_ALTSTARTUP = (0x001e), // The file system directory that corresponds to the
  297.         // nonlocalized Startup program group for all users. Valid only
  298.         // for Microsoft Windows NT® systems.
  299.         CSIDL_COMMON_APPDATA = (0x0023), // Version 5.0. The file system directory containing application
  300.         // data for all users. A typical path is C:\Documents and
  301.         // Settings\All Users\Application Data.
  302.         CSIDL_COMMON_DESKTOPDIRECTORY = (0x0019), // The file system directory that contains files and folders
  303.         // that appear on the desktop for all users. A typical path is
  304.         // C:\Documents and Settings\All Users\Desktop. Valid only for
  305.         // Windows NT systems.
  306.         CSIDL_COMMON_DOCUMENTS = (0x002e), // The file system directory that contains documents that are
  307.         // common to all users. A typical paths is C:\Documents and
  308.         // Settings\All Users\Documents. Valid for Windows NT systems
  309.         // and Microsoft Windows® 95 and Windows 98 systems with
  310.         // Shfolder.dll installed.
  311.         CSIDL_COMMON_FAVORITES = (0x001f), // The file system directory that serves as a common repository
  312.         // for favorite items common to all users. Valid only for
  313.         // Windows NT systems.
  314.         CSIDL_COMMON_MUSIC = (0x0035), // Version 6.0. The file system directory that serves as a
  315.         // repository for music files common to all users. A typical
  316.         // path is C:\Documents and Settings\All Users\Documents\
  317.         // My Music.
  318.         CSIDL_COMMON_PICTURES = (0x0036), // Version 6.0. The file system directory that serves as a
  319.         // repository for image files common to all users. A typical
  320.         // path is C:\Documents and Settings\All Users\Documents\
  321.         // My Pictures.
  322.         CSIDL_COMMON_PROGRAMS = (0x0017), // The file system directory that contains the directories for
  323.         // the common program groups that appear on the Start menu for
  324.         // all users. A typical path is C:\Documents and Settings\
  325.         // All Users\Start Menu\Programs. Valid only for Windows NT
  326.         // systems.
  327.         CSIDL_COMMON_STARTMENU = (0x0016), // The file system directory that contains the programs and
  328.         // folders that appear on the Start menu for all users. A
  329.         // typical path is C:\Documents and Settings\All Users\
  330.         // Start Menu. Valid only for Windows NT systems.
  331.         CSIDL_COMMON_STARTUP = (0x0018), // The file system directory that contains the programs that
  332.         // appear in the Startup folder for all users. A typical path
  333.         // is C:\Documents and Settings\All Users\Start Menu\Programs\
  334.         // Startup. Valid only for Windows NT systems.
  335.         CSIDL_COMMON_TEMPLATES = (0x002d), // The file system directory that contains the templates that
  336.         // are available to all users. A typical path is C:\Documents
  337.         // and Settings\All Users\Templates. Valid only for Windows
  338.         // NT systems.
  339.         CSIDL_COMMON_VIDEO = (0x0037), // Version 6.0. The file system directory that serves as a
  340.         // repository for video files common to all users. A typical
  341.         // path is C:\Documents and Settings\All Users\Documents\
  342.         // My Videos.
  343.         CSIDL_CONTROLS = (0x0003), // The virtual folder containing icons for the Control Panel
  344.         // applications.
  345.         CSIDL_COOKIES = (0x0021), // The file system directory that serves as a common repository
  346.         // for Internet cookies. A typical path is C:\Documents and
  347.         // Settings\username\Cookies.
  348.         CSIDL_DESKTOP = (0x0000), // The virtual folder representing the Windows desktop, the root
  349.         // of the namespace.
  350.         CSIDL_DESKTOPDIRECTORY = (0x0010), // The file system directory used to physically store file
  351.         // objects on the desktop (not to be confused with the desktop
  352.         // folder itself). A typical path is C:\Documents and
  353.         // Settings\username\Desktop.
  354.         CSIDL_DRIVES = (0x0011), // The virtual folder representing My Computer, containing
  355.         // everything on the local computer: storage devices, printers,
  356.         // and Control Panel. The folder may also contain mapped
  357.         // network drives.
  358.         CSIDL_FAVORITES = (0x0006), // The file system directory that serves as a common repository
  359.         // for the user's favorite items. A typical path is C:\Documents
  360.         // and Settings\username\Favorites.
  361.         CSIDL_FONTS = (0x0014), // A virtual folder containing fonts. A typical path is
  362.         // C:\Windows\Fonts.
  363.         CSIDL_HISTORY = (0x0022), // The file system directory that serves as a common repository
  364.         // for Internet history items.
  365.         CSIDL_INTERNET = (0x0001), // A virtual folder representing the Internet.
  366.         CSIDL_INTERNET_CACHE = (0x0020), // Version 4.72. The file system directory that serves as a
  367.         // common repository for temporary Internet files. A typical
  368.         // path is C:\Documents and Settings\username\Local Settings\
  369.         // Temporary Internet Files.
  370.         CSIDL_LOCAL_APPDATA = (0x001c), // Version 5.0. The file system directory that serves as a data
  371.         // repository for local (nonroaming) applications. A typical
  372.         // path is C:\Documents and Settings\username\Local Settings\
  373.         // Application Data.
  374.         CSIDL_MYDOCUMENTS = (0x000c), // Version 6.0. The virtual folder representing the My Documents
  375.         // desktop item. This should not be confused with
  376.         // CSIDL_PERSONAL, which represents the file system folder that
  377.         // physically stores the documents.
  378.         CSIDL_MYMUSIC = (0x000d), // The file system directory that serves as a common repository
  379.         // for music files. A typical path is C:\Documents and Settings
  380.         // \User\My Documents\My Music.
  381.         CSIDL_MYPICTURES = (0x0027), // Version 5.0. The file system directory that serves as a
  382.         // common repository for image files. A typical path is
  383.         // C:\Documents and Settings\username\My Documents\My Pictures.
  384.         CSIDL_MYVIDEO = (0x000e), // Version 6.0. The file system directory that serves as a
  385.         // common repository for video files. A typical path is
  386.         // C:\Documents and Settings\username\My Documents\My Videos.
  387.         CSIDL_NETHOOD = (0x0013), // A file system directory containing the link objects that may
  388.         // exist in the My Network Places virtual folder. It is not the
  389.         // same as CSIDL_NETWORK, which represents the network namespace
  390.         // root. A typical path is C:\Documents and Settings\username\
  391.         // NetHood.
  392.         CSIDL_NETWORK = (0x0012), // A virtual folder representing Network Neighborhood, the root
  393.         // of the network namespace hierarchy.
  394.         CSIDL_PERSONAL = (0x0005), // The file system directory used to physically store a user's
  395.         // common repository of documents. A typical path is
  396.         // C:\Documents and Settings\username\My Documents. This should
  397.         // be distinguished from the virtual My Documents folder in
  398.         // the namespace, identified by CSIDL_MYDOCUMENTS.
  399.         CSIDL_PRINTERS = (0x0004), // The virtual folder containing installed printers.
  400.         CSIDL_PRINTHOOD = (0x001b), // The file system directory that contains the link objects that
  401.         // can exist in the Printers virtual folder. A typical path is
  402.         // C:\Documents and Settings\username\PrintHood.
  403.         CSIDL_PROFILE = (0x0028), // Version 5.0. The user's profile folder. A typical path is
  404.         // C:\Documents and Settings\username. Applications should not
  405.         // create files or folders at this level; they should put their
  406.         // data under the locations referred to by CSIDL_APPDATA or
  407.         // CSIDL_LOCAL_APPDATA.
  408.         CSIDL_PROFILES = (0x003e), // Version 6.0. The file system directory containing user
  409.         // profile folders. A typical path is C:\Documents and Settings.
  410.         CSIDL_PROGRAM_FILES = (0x0026), // Version 5.0. The Program Files folder. A typical path is
  411.         // C:\Program Files.
  412.         CSIDL_PROGRAM_FILES_COMMON = (0x002b), // Version 5.0. A folder for components that are shared across
  413.         // applications. A typical path is C:\Program Files\Common.
  414.         // Valid only for Windows NT, Windows 2000, and Windows XP
  415.         // systems. Not valid for Windows Millennium Edition
  416.         // (Windows Me).
  417.         CSIDL_PROGRAMS = (0x0002), // The file system directory that contains the user's program
  418.         // groups (which are themselves file system directories).
  419.         // A typical path is C:\Documents and Settings\username\
  420.         // Start Menu\Programs.
  421.         CSIDL_RECENT = (0x0008), // The file system directory that contains shortcuts to the
  422.         // user's most recently used documents. A typical path is
  423.         // C:\Documents and Settings\username\My Recent Documents.
  424.         // To create a shortcut in this folder, use SHAddToRecentDocs.
  425.         // In addition to creating the shortcut, this function updates
  426.         // the Shell's list of recent documents and adds the shortcut
  427.         // to the My Recent Documents submenu of the Start menu.
  428.         CSIDL_SENDTO = (0x0009), // The file system directory that contains Send To menu items.
  429.         // A typical path is C:\Documents and Settings\username\SendTo.
  430.         CSIDL_STARTMENU = (0x000b), // The file system directory containing Start menu items. A
  431.         // typical path is C:\Documents and Settings\username\Start Menu.
  432.         CSIDL_STARTUP = (0x0007), // The file system directory that corresponds to the user's
  433.         // Startup program group. The system starts these programs
  434.         // whenever any user logs onto Windows NT or starts Windows 95.
  435.         // A typical path is C:\Documents and Settings\username\
  436.         // Start Menu\Programs\Startup.
  437.         CSIDL_SYSTEM = (0x0025), // Version 5.0. The Windows System folder. A typical path is
  438.         // C:\Windows\System32.
  439.         CSIDL_TEMPLATES = (0x0015), // The file system directory that serves as a common repository
  440.         // for document templates. A typical path is C:\Documents
  441.         // and Settings\username\Templates.
  442.         CSIDL_WINDOWS = (0x0024), // Version 5.0. The Windows directory or SYSROOT. This
  443.         // corresponds to the %windir% or %SYSTEMROOT% environment
  444.         // variables. A typical path is C:\Windows.
  445.     }
  446.  
  447.     [ComImport]
  448.     [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  449.     [Guid("000214F2-0000-0000-C000-000000000046")]
  450.     public interface IEnumIDList
  451.     {
  452.  
  453.         /// <summary>
  454.         /// Retrieves the specified number of item identifiers in the
  455.         /// enumeration sequence and advances the current position by
  456.         /// the number of items retrieved.
  457.         /// </summary>
  458.         /// <param name="celt">Number of elements in the array pointed to by the rgelt parameter.</param>
  459.         /// <param name="rgelt">
  460.         /// Address of an array of ITEMIDLIST pointers that receives the item identifiers. The implementation must allocate these item identifiers
  461.         /// using the Shell's allocator (retrieved by the SHGetMalloc function). The calling application is responsible for freeing the item
  462.         /// identifiers using the Shell's allocator.
  463.         /// </param>
  464.         /// <param name="pceltFetched">
  465.         /// Address of a value that receives a count of the item identifiers actually returned in rgelt. The count can be smaller than the value
  466.         /// specified in the celt parameter. This parameter can be NULL only if celt is one.
  467.         /// </param>
  468.         [PreserveSig()]
  469.         uint Next(uint celt, [MarshalAs(UnmanagedType.LPArray)] IntPtr[] rgelt, out int pceltFetched);
  470.  
  471.         /// <summary>
  472.         /// Skips over the specified number of elements in the enumeration sequence.
  473.         /// </summary>
  474.         /// <param name="celt">Number of item identifiers to skip.</param>
  475.         [PreserveSig()]
  476.         uint Skip(uint celt);
  477.  
  478.         /// <summary>
  479.         /// Returns to the beginning of the enumeration sequence.
  480.         /// </summary>
  481.         [PreserveSig()]
  482.         uint Reset();
  483.  
  484.         /// <summary>
  485.         /// Creates a new item enumeration object with the same contents and state as the current one.
  486.         /// </summary>
  487.         /// <param name="ppenum">
  488.         /// Address of a pointer to the new enumeration object. The calling application must
  489.         /// eventually free the new object by calling its Release member function.
  490.         /// </param>
  491.         [PreserveSig()]
  492.         uint Clone(out IEnumIDList ppenum);
  493.     }
  494.  
  495.     [Flags]
  496.     public enum SHGFI : int
  497.     {
  498.         /// <summary>get icon</summary>
  499.         Icon = 0x000000100,
  500.         /// <summary>get display name</summary>
  501.         DisplayName = 0x000000200,
  502.         /// <summary>get type name</summary>
  503.         TypeName = 0x000000400,
  504.         /// <summary>get attributes</summary>
  505.         Attributes = 0x000000800,
  506.         /// <summary>get icon location</summary>
  507.         IconLocation = 0x000001000,
  508.         /// <summary>return exe type</summary>
  509.         ExeType = 0x000002000,
  510.         /// <summary>get system icon index</summary>
  511.         SysIconIndex = 0x000004000,
  512.         /// <summary>put a link overlay on icon</summary>
  513.         LinkOverlay = 0x000008000,
  514.         /// <summary>show icon in selected state</summary>
  515.         Selected = 0x000010000,
  516.         /// <summary>get only specified attributes</summary>
  517.         Attr_Specified = 0x000020000,
  518.         /// <summary>get large icon</summary>
  519.         LargeIcon = 0x000000000,
  520.         /// <summary>get small icon</summary>
  521.         SmallIcon = 0x000000001,
  522.         /// <summary>get open icon</summary>
  523.         OpenIcon = 0x000000002,
  524.         /// <summary>get shell size icon</summary>
  525.         ShellIconSize = 0x000000004,
  526.         /// <summary>pszPath is a pidl</summary>
  527.         PIDL = 0x000000008,
  528.         /// <summary>use passed dwFileAttribute</summary>
  529.         UseFileAttributes = 0x000000010,
  530.         /// <summary>apply the appropriate overlays</summary>
  531.         AddOverlays = 0x000000020,
  532.         /// <summary>Get the index of the overlay in the upper 8 bits of the iIcon</summary>
  533.         OverlayIndex = 0x000000040,
  534.     }
  535. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement