IPropertyDescription::FormatForDisplay method (propsys.h)

Gets a formatted, Unicode string representation of a property value.


HRESULT FormatForDisplay(
  REFPROPVARIANT        propvar,
  LPWSTR                *ppszDisplay




A reference to a PROPVARIANT structure that contains the type and value of the property.



One or more of the PROPDESC_FORMAT_FLAGS flags, which are either bitwise or multiple values, that indicate the property string format.



The address of a pointer to a null-terminated Unicode string that contains the display text.

Return value


Returns one of the following values.

Return code Description
The string was copied and null-terminated without truncation. This string may be returned empty due to an empty input string or from a non-empty value that was formatted as an empty string.
The empty string resulted from a VT_EMPTY.
The pszText parameter is NULL.
The copy operation failed due to insufficient space. The destination buffer is modified to contain a truncated version of the ideal result and is null-terminated.


You must initialize Component Object Model (COM) with CoInitialize or OleInitialize before calling IPropertyDescription::FormatForDisplay.

On success, this method gets a formatted Unicode string representation of a property value for a specified PROPERTYKEY, and one or more PROPDESC_FORMAT_FLAGS.

The purpose of this method is to convert data into a string suitable for display to the user. The value is formatted according to the current locale, the language of the user, the PROPDESC_FORMAT_FLAGS, and the property description specified by the property key. For information about how the property description schema influences the formatting of the value, see displayInfo, stringFormat, booleanFormat, numberFormat, NMDATETIMEFORMAT, and enumeratedList. Typically, the PROPDESC_FORMAT_FLAGS are used to modify the format prescribed by the property description.

The output string can contain Unicode directional characters. These nonspacing characters influence the Unicode bidirectional algorithm so that the values appear correctly when a left-to-right (LTR) language is drawn onto a right-to-left (RTL) window, and vice versa. These characters include the following: "\x200e", "\x200f", "\x202a", "\x202b", "\x202c", "\x202d", "\x202e".

The following properties use special formats and are unaffected by the PROPDESC_FORMAT_FLAGS (examples cited are for strings with a current locale set to English; typically, output is localized except where noted).

Property Format
System.FileAttributes The following file attributes are converted to letters and appended to create a string (for example, a value of 0x1801 (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_OFFLINE) is converted to "RCO"):
  • FILE_ATTRIBUTE_READONLY (0x00000001) - 'R'
  • FILE_ATTRIBUTE_SYSTEM (0x00000004) - 'S'
  • FILE_ATTRIBUTE_ARCHIVE (0x00000020) -'A'
  • FILE_ATTRIBUTE_COMPRESSED (0x00000800) - 'C'
  • FILE_ATTRIBUTE_ENCRYPTED (0x00004000) - 'E'
  • FILE_ATTRIBUTE_OFFLINE (0x00001000) - 'O'
System.Photo.ISOSpeed For example, "ISO-400".
System.Photo.ShutterSpeed The APEX value is converted to an exposure time using this formula:

Exposure_time = 2^(-APEX_value)

For example, "2 sec."or "1/125 sec.".

System.Photo.ExposureTime For example, "2 sec."or "1/125 sec."
System.Photo.Aperture The APEX value is converted to an F number using this formula:

F_Number = 2^(APEX_Value / 2)

For example, "f/5.6".

System.Photo.FNumber For example, "f/5.6".
System.Photo.SubjectDistance For example, "15 m"or "250 mm".
System.Photo.FocalLength For example, "50 mm".
System.Photo.FlashEnergy For example, "500 bpcs".
System.Photo.ExposureBias For example, "-2 step", " 0 step", or "+3 step".
System.Computer.DecoratedFreeSpace For example, "105 MB free of 13.2 GB".
System.ItemType For example, "Application" or "JPEG Image".
System.ComputerName For example, "LITWARE05 (this computer)" or "testbox07".


Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header propsys.h

See also


Property Description Schema