Platform SDK: International Features

GetCurrencyFormat

The GetCurrencyFormat function formats a number string as a currency string for a specified locale.

int GetCurrencyFormat(
  LCID Locale,                  // locale
  DWORD dwFlags,                // operation option
  LPCTSTR lpValue,              // input number string
  CONST CURRENCYFMT *lpFormat,  // formatting information
  LPTSTR lpCurrencyStr,         // output buffer
  int cchCurrency               // size of output buffer
);

Parameters

Locale
[in] Specifies the locale for which the currency string is to be formatted. If lpFormat is NULL, the function formats the string according to the currency format for this locale. If lpFormat is not NULL, the function uses the locale only for formatting information not specified in the CURRENCYFMT structure (for example, the locale's string value for the negative sign).

This parameter can be a locale identifier created by the MAKELCID macro, or one of the following predefined values.
Value Meaning
LOCALE_SYSTEM_DEFAULT Default system locale.
LOCALE_USER_DEFAULT Default user locale.

dwFlags
[in] Controls the operation of the function. If lpFormat is non-NULL, this parameter must be zero.

If lpFormat is NULL, you can specify the LOCALE_NOUSEROVERRIDE flag to format the string using the system default currency format for the specified locale; or you can specify zero to format the string using any user overrides to the locale's default currency format.

lpValue
[in] Pointer to a null-terminated string containing the number string to format.

This string can contain only the following characters:

All other characters are invalid. The function returns an error if the string pointed to by lpValue deviates from these rules.

lpFormat
[in] Pointer to a CURRENCYFMT structure that contains currency formatting information. All members in the structure pointed to by lpFormat must contain appropriate values.

If lpFormat is NULL, the function uses the currency format of the specified locale.

lpCurrencyStr
[out] Pointer to a buffer that receives the formatted currency string.
cchCurrency
[in] Specifies the size, in TCHARs, of the lpCurrencyStr buffer. If cchCurrency is zero, the function returns the number of TCHARs required to hold the formatted currency string, and the buffer pointed to by lpCurrencyStr is not used.

Return Values

If the function succeeds, the return value is the number of TCHARs written to the buffer pointed to by lpCurrencyStr, or if the cchCurrency parameter is zero, the number of bytes or characters required to hold the formatted currency string. The count includes the terminating null.

If the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError may return one of the following error codes:

Remarks

Windows 2000: The ANSI version of this function will fail if it is used with a Unicode-only LCID. See Language Identifiers.

Requirements

  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winnls.h; include Windows.h.
  Library: Use Kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

National Language Support Overview, National Language Support Functions, GetNumberFormat, CURRENCYFMT