Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function formats a number string as a number string customized for a specified locale.

Note:
If you specify a locale with the LCID (Locale ID) parameter and that locale is not installed or available on the Windows ®phone, the function fails with ERROR_INVALID_PARAMETER. To determine whether the locale is supported or not, call IsValidLocale.

Syntax

int GetNumberFormat(
  LCID 
Locale, 
  DWORD 
dwFlags, 
  LPCTSTR 
lpValue, 
  const NUMBERFMT* 
lpFormat, 
  LPTSTR 
lpNumberStr, 
  int 
cchNumber 
); 

Parameters

Locale

[in] Value that specifies the locale for which the number string is to be formatted. If lpFormatis NULL, the function formats the string according to the number format for this locale. If lpFormatis not NULL, the function uses the locale only for formatting information not specified in the NUMBERFMTstructure (for example, the locale's string value for the negative sign).

This parameter can be a locale identifier created by the MAKELCIDmacro, or one of the following predefined values. The following table shows the values this parameter can take.

Value Description

LOCALE_SYSTEM_DEFAULT

Default system locale.

LOCALE_USER_DEFAULT

Default user locale.

LOCALE_NEUTRAL

Default language-neutral locale.

dwFlags

[in] Bit flag that controls the operation of the function. If lpFormatis non-NULL, this parameter must be zero.

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

lpValue

[in] Pointer to a null-terminated string that contains the number string to format.

This string can only contain the following characters:

  • Characters '0' through '9'

  • One decimal point (dot) if the number is a floating-point value

  • A minus sign in the first character position if the number is a negative value

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

lpFormat

[in] Pointer to a NUMBERFMTstructure that contains number formatting information. All members in the structure pointed to by lpFormatmust contain appropriate values.

If lpFormatis NULL, the function uses the number format of the specified locale.

lpNumberStr

[out] Pointer to a buffer to receive the formatted number string.

cchNumber

[in] Size, in characters, of the lpNumberStrbuffer. If cchNumberis zero, the function returns the number of characters required to hold the formatted number string, and the buffer pointed to by lpNumberStris not used.

Return Value

The number of characters written to the buffer pointed to by lpNumberStr, or, if the cchNumberparameter is zero, the number of characters required to hold the formatted number string indicates success. The count includes the terminating null. Zero indicates failure. To get extended error information, call the GetLastErrorfunction. The following table shows possible return values for GetLastError.

Value Description

ERROR_INSUFFICIENT_BUFFER

The data area passed to a system call is too small.

ERROR_INVALID FLAGS

The flags are invalid.

ERROR_INVALID_PARAMETER

The parameter is incorrect, or the specified LCID is not supported on the device.

Remarks

For more information about locales and LCID, see National Language support (NLS) Locale Identifiers.

Requirements

Header winnls.h
Library Coreloc.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also