Export (0) Print
Expand All
Expand Minimize

GetCurrencyFormat function

Formats a number string as a currency string for a locale specified by identifier.

Note  For interoperability reasons, the application should prefer the GetCurrencyFormatEx function to GetCurrencyFormat because Microsoft is migrating toward the use of locale names instead of locale identifiers for new locales. Any application that runs only on Windows Vista and later should use GetCurrencyFormatEx.

Syntax


int GetCurrencyFormat(
  _In_       LCID Locale,
  _In_       DWORD dwFlags,
  _In_       LPCTSTR lpValue,
  _In_opt_   const CURRENCYFMT *lpFormat,
  _Out_opt_  LPTSTR lpCurrencyStr,
  _In_       int cchCurrency
);

Parameters

Locale [in]

Locale identifier that specifies the locale for which this function formats the currency string. You can use the MAKELCID macro to create a locale identifier or use one of the following predefined values.

dwFlags [in]

Flags controlling currency format. The application must set this parameter to 0 if lpFormat is not set to NULL. In this case, the function formats the string using user overrides to the default currency format for the locale. If lpFormat is set to NULL, the application can specify LOCALE_NOUSEROVERRIDE to format the string using the system default currency format for the specified locale.

Caution  Use of LOCALE_NOUSEROVERRIDE is strongly discouraged as it disables user preferences.

lpValue [in]

For details, see the lpValue parameter of GetCurrencyFormatEx.

lpFormat [in, optional]

Pointer to a CURRENCYFMT structure that contains currency formatting information. All members of the structure must contain appropriate values. The application can set this parameter to NULL if function is to use the currency format of the specified locale. If this parameter is not set to NULL, the function uses the specified locale only for formatting information not specified in the CURRENCYFMT structure, for example, the string value for the negative sign used by the locale.

lpCurrencyStr [out, optional]

Pointer to a buffer in which this function retrieves the formatted currency string.

cchCurrency [in]

Size, in characters, of the lpCurrencyStr buffer. The application sets this parameter to 0 if the function is to return the size of the buffer required to hold the formatted currency string. In this case, the lpCurrencyStr parameter is not used.

Return value

Returns the number of characters retrieved in the buffer indicated by lpCurrencyStr if successful. If the cchCurrency parameter is set to 0, the function returns the size of the buffer required to hold the formatted currency string, including a terminating null character.

The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
  • ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.

Remarks

This function can retrieve data from custom locales. Data is not guaranteed to be the same from computer to computer or between runs of an application. If your application must persist or transmit data, see Using Persistent Locale Data.

When the ANSI version of this function is used with a Unicode-only locale identifier, the call can succeed because the operating system uses the system code page. However, characters that are undefined in the system code page appear in the string as a question mark (?).

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winnls.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

GetCurrencyFormatW (Unicode) and GetCurrencyFormatA (ANSI)

See also

National Language Support
National Language Support Functions
GetCurrencyFormatEx
GetNumberFormat
CURRENCYFMT

 

 

Community Additions

ADD
Show:
© 2014 Microsoft