예제 #1
0
        public static string GetDisplayName(IntPtr pIDL, bool fDisplayName)
        {
            IShellFolder ppv  = null;
            Guid         riid = ExplorerGUIDs.IID_IShellFolder;

            try {
                IntPtr ptr;
                STRRET strret;
                if ((PInvoke.SHBindToParent(pIDL, riid, out ppv, out ptr) != 0) || (ppv == null))
                {
                    return(string.Empty);
                }
                uint          uFlags = fDisplayName ? 0 : 0x8000u;
                StringBuilder pszBuf = new StringBuilder(260);
                if (ppv.GetDisplayNameOf(ptr, uFlags, out strret) == 0)
                {
                    PInvoke.StrRetToBuf(ref strret, ptr, pszBuf, pszBuf.Capacity);
                }
                return(pszBuf.ToString());
            }
            catch {
            }
            finally {
                if (ppv != null)
                {
                    Marshal.ReleaseComObject(ppv);
                }
            }
            return(string.Empty);
        }
예제 #2
0
        public static string GetDisplayName(IShellFolder shellFolder, IntPtr pIDLLast, bool fDisplayName)
        {
            STRRET        strret;
            uint          uFlags = fDisplayName ? 0 : 0x8000u;
            StringBuilder pszBuf = new StringBuilder(260);

            if (shellFolder.GetDisplayNameOf(pIDLLast, uFlags, out strret) == 0)
            {
                PInvoke.StrRetToBuf(ref strret, pIDLLast, pszBuf, pszBuf.Capacity);
            }
            return(pszBuf.ToString());
        }