<p>I'm trying to find out the 'correct' windows API for finding out the localized name of 'special' folders, specifically the Recycle Bin. I want to be able to prompt the user with a suitably localized dialog box asking them if they want to send files to the recycle bin or delete them directly.</p>

<p>I've found lots on the internet (and on Stackoverflow) about how to do the actual deletion, and it seems simple enough, I just really want to be able to have the text localized.</p>

[{'answer_id': 37055, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 3, 'selected': True, 'text': '<p>Read this article for code samples and usage:</p>\n\n<p><a href="http://www.codeproject.com/KB/winsdk/SpecialFolders.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/winsdk/SpecialFolders.aspx</a></p>\n\n<p>Also there is an article on MSDN that helps you <a href="http://msdn.microsoft.com/en-us/library/aa140088(office.10).aspx" rel="nofollow noreferrer">Identify the Location of Special Folders with API Calls</a></p>\n'}, {'answer_id': 7417694, 'author': 'ladenedge', 'author_id': 222481, 'author_profile': 'https://Stackoverflow.com/users/222481', 'pm_score': 0, 'selected': False, 'text': '<p>I actually didn\'t find the CodeProject article terribly helpful, so I thought I\'d answer this question with the actual code that I used to retrieve the localized name of the recycle bin.</p>\n\n<p>This sample also tries to behave correctly with regard to freeing resources.  Any comments are welcome, especially if you spot an error with my resource management!</p>\n\n<pre><code>public static string GetLocalizedRecycleBinName()\n{\n   IntPtr relative_pidl, parent_ptr, absolute_pidl;\n\n   PInvoke.SHGetFolderLocation(IntPtr.Zero, PInvoke.CSIDL.BitBucket,\n         IntPtr.Zero, 0, out absolute_pidl);\n   try\n   {\n      PInvoke.SHBindToParent(absolute_pidl,\n            ref PInvoke.Guids.IID_IShellFolder,\n            out parent_ptr, out relative_pidl);\n      PInvoke.IShellFolder shell_folder =\n            Marshal.GetObjectForIUnknown(parent_ptr)\n            as PInvoke.IShellFolder;\n      // Release() for this object is called at finalization\n      if (shell_folder == null)\n         return Strings.RecycleBin;\n\n      PInvoke.STRRET strret = new PInvoke.STRRET();\n      StringBuilder sb = new StringBuilder(260);\n      shell_folder.GetDisplayNameOf(relative_pidl, PInvoke.SHGNO.Normal,\n            out strret);\n      PInvoke.StrRetToBuf(ref strret, relative_pidl, sb, 260);\n      string name = sb.ToString();\n\n      return String.IsNullOrEmpty(name) ? Strings.RecycleBin : name;\n   }\n   finally { PInvoke.ILFree(absolute_pidl); }\n}\n\nstatic class PInvoke\n{\n   [DllImport("shell32.dll")]\n   public static extern int SHGetFolderLocation(IntPtr hwndOwner,\n         CSIDL nFolder, IntPtr hToken, uint dwReserved, out IntPtr ppidl);\n\n   [DllImport("shell32.dll")]\n   public static extern int SHBindToParent(IntPtr lpifq, [In] ref Guid riid,\n         out IntPtr ppv, out IntPtr pidlLast);\n\n   [DllImport("shlwapi.dll")]\n   public static extern Int32 StrRetToBuf(ref STRRET pstr, IntPtr pidl,\n         StringBuilder pszBuf, uint cchBuf);\n\n   [DllImport("shell32.dll")]\n   public static extern void ILFree([In] IntPtr pidl);\n\n   [ComImport]\n   [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\n   [Guid("000214E6-0000-0000-C000-000000000046")]\n   public interface IShellFolder\n   {\n      [PreserveSig]\n      Int32 CompareIDs(Int32 lParam, IntPtr pidl1, IntPtr pidl2);\n      void ParseDisplayName(IntPtr hwnd, IntPtr pbc, String pszDisplayName,\n            UInt32 pchEaten, out IntPtr ppidl, UInt32 pdwAttributes);\n      void EnumObjects(IntPtr hwnd, int grfFlags,\n            out IntPtr ppenumIDList);\n      void BindToObject(IntPtr pidl, IntPtr pbc, [In] ref Guid riid,\n            out IntPtr ppv);\n      void BindToStorage(IntPtr pidl, IntPtr pbc, [In] ref Guid riid,\n            out IntPtr ppv);\n      void CreateViewObject(IntPtr hwndOwner, [In] ref Guid riid,\n            out IntPtr ppv);\n      void GetAttributesOf(UInt32 cidl,\n            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]\n         IntPtr[] apidl, ref uint rgfInOut);\n      void GetUIObjectOf(IntPtr hwndOwner, UInt32 cidl,\n            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]\n         IntPtr[] apidl, [In] ref Guid riid, UInt32 rgfReserved,\n         out IntPtr ppv);\n      void GetDisplayNameOf(IntPtr pidl, SHGNO uFlags, out STRRET pName);\n      void SetNameOf(IntPtr hwnd, IntPtr pidl, string pszName,\n            int uFlags, out IntPtr ppidlOut);\n   }\n\n   public enum CSIDL\n   {\n      BitBucket = 0x000a,\n   }\n\n   public enum SHGNO\n   {\n      Normal = 0x0000, ForParsing = 0x8000,\n   }\n\n   [StructLayout(LayoutKind.Explicit, Size = 520)]\n   public struct STRRETinternal\n   {\n      [FieldOffset(0)] public IntPtr pOleStr;\n      [FieldOffset(0)] public IntPtr pStr;\n      [FieldOffset(0)] public uint uOffset;\n   }\n\n   [StructLayout(LayoutKind.Sequential)]\n   public struct STRRET\n   {\n      public uint uType;\n      public STRRETinternal data;\n   }\n\n   public class Guids\n   {\n      public static Guid IID_IShellFolder =\n            new Guid("{000214E6-0000-0000-C000-000000000046}");\n   }\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/37053', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1849/']