Retrieves the display name for the specified file object or subfolder.
HRESULT GetDisplayNameOf( PCUITEMID_CHILD pidl, SHGDNF uFlags, STRRET *pName );
PIDL that uniquely identifies the file object or subfolder relative to the parent folder.
Flags used to request the type of display name to return. For a list of possible values, see the SHGDNF enumerated type.
When this method returns, contains a pointer to 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.
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
It is the caller's responsibility to free resources allocated by this function.
Normally, 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. At one time, pidl could be a multilevel PIDL, relative to the parent folder, and could contain multiple SHITEMID structures. However, this is no longer supported and pidl should now refer only to a single child item.
The simplest way to retrieve the display name from the structure pointed to by pName is to pass it to either StrRetToBuf or StrRetToStr. These functions take a STRRET structure and return 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 the GetDisplayNameOf/ParseDisplayName round trip to not return the original identifier list. This occurrence is exceptional, but you should check to be sure.
|Minimum supported client||Windows XP [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||shobjidl_core.h (include Shobjidl.h)|
|DLL||Shell32.dll (version 4.0 or later)|