예제 #1
0
        /// <summary>
        /// Translates the display name of a file object or a folder into an item identifier list.
        /// </summary>
        /// <param name="hwnd">A window handle. The client should provide a window handle if it displays a dialog or message box. Otherwise set hwnd to NULL.</param>
        /// <param name="pbc">Optional. A pointer to a bind context used to pass parameters as inputs and outputs to the parsing function.</param>
        /// <param name="pszDisplayName">A null-terminated Unicode string with the display name.</param>
        /// <param name="pchEaten">A pointer to a ULONG value that receives the number of characters of the display name that was parsed. If your application does not need this information, set pchEaten to NULL, and no value will be returned.</param>
        /// <param name="ppidl">When this method returns, contains a pointer to the PIDL for the object.</param>
        /// <param name="pdwAttributes">The value used to query for file attributes. If not used, it should be set to NULL.</param>
        /// <returns>
        /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
        /// </returns>
        /// <exception cref="System.NotImplementedException"></exception>
        int IShellFolder.ParseDisplayName(IntPtr hwnd, IntPtr pbc, string pszDisplayName, ref uint pchEaten, out IntPtr ppidl, ref SFGAO pdwAttributes)
        {
            //  First we can decode the pidl from the display name.
            var idList = IdList.FromParsingString(pszDisplayName);

            ppidl = PidlManager.IdListToPidl(idList);

            //  We always eat the entire display string for SharpShell PIDL/DisplayName parsing.
            pchEaten = (uint)pszDisplayName.Length;


            //  In theory, we should understand the pidl.
            var item = GetChildItem(idList);
            var name = item.GetDisplayName(DisplayNameContext.Normal);

            //  TODO: We may be asked to get the attributes at the same time. If so, we must set them here.
            return(WinError.S_OK);
        }