Partager via


IShellFolder::GetDisplayNameOf (Compact 2013)

3/28/2014

This method retrieves the display name for the specified file object or subfolder.

Syntax

HRESULT GetDisplayNameOf(
  LPCITEMIDLIST pidl,
  DWORD uFlags,
  LPSTRRET lpName
);

Parameters

  • pidl
    [in] Pointer to an ITEMIDLIST structure (PIDL) that uniquely identifies the file object or subfolder relative to the parent folder.
  • uFlags
    [in] Flags used to request the type of display name to return. For a list of possible values, see the SHGNO enumerated type.
  • lpName
    [out] Address of a STRRET structure in which to return the display name. The type of name returned in this structure can be the requested type, but the shell folder might return a different type.

Return Value

Returns NOERROR if successful, or an error value otherwise.

Remarks

Typically, pidl can refer only to items contained by the parent folder. The PIDL must be single-level and contain exactly one SHITEMID structure followed by a terminating zero. If you want to retrieve the display name of an item that is deeper than one level away from the parent folder, use SHBindToParent to bind with the item's immediate parent folder and then pass the item's single-level PIDL to IShellFolder::GetDisplayNameOf.

Also, if the SHGDN_FORPARSING flag is set in uFlags and the SHGDN_INFOLDER flag is not set, pidl can refer to an object at any level below the parent folder in the namespace hierarchy. In this case, pidl can be a multilevel PIDL, relative to the parent folder, and can contain multiple SHITEMID structures.

The simplest way to retrieve the display name from the structure pointed to by lpName is to pass it to StrRetToBuf. This function takes a STRRET structure and returns the name. You can also examine the structure's uType member and retrieve the name from the appropriate member.

The flags specified in uFlags are hints about the intended use of the name. They do not guarantee that IShellFolder will return the requested form of the name. If that form is not available, a different one might be returned. In particular, there is no guarantee that the name returned by the SHGDN_FORPARSING flag will be successfully parsed by IShellFolder::ParseDisplayName. There are also some combinations of flags that might cause an IShellFolder::GetDisplayNameOf call with a subsequent IShellFolder::ParseDisplayName call to not return the original identifier list. This occurrence is exceptional, but you should check to be sure.

The parsing name that is returned when uFlags has the SHGDN_FORPARSING flag set is not necessarily a typical text string. Virtual folders such as My Computer might return a string containing the folder object's GUID in the form "::{GUID}". Developers who implement IShellFolder::GetDisplayNameOf are encouraged to return parse names that are as close to the display names as possible, because the end user often needs to type or edit these names.

Requirements

Header

shobjidl.h,
shobjidl.idl

Library

Developer Implemented

See Also

Reference

IShellFolder
ITEMIDLIST
SHGNO
STRRET
SHITEMID
SHBindToParent
StrRetToBuf
IShellFolder::ParseDisplayName