GetNumberFormat

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

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

Parameters

  • Locale
    [in] Specifies the locale for which the number string is to be formatted. If lpFormat is NULL, the function formats the string according to the number format for this locale. If lpFormat is not NULL, the function uses the locale only for formatting information not specified in the NUMBERFMT 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 Description
    LOCALE_SYSTEM_DEFAULT Default system locale.
    LOCALE_USER_DEFAULT Default user locale.
    LOCALE_NEUTRAL Default language-neutral locale.
  • dwFlags
    [in] Contains a bit flag that 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 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 lpValue deviates from these rules.

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

    If lpFormat is 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] Specifies the size, in characters, of the lpNumberStr buffer. If cchNumber is zero, the function returns the number of characters required to hold the formatted number string, and the buffer pointed to by lpNumberStr is not used.

Return Values

The number of characters written to the buffer pointed to by lpNumberStr, or, if the cchNumber parameter 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 GetLastError. Possible values for GetLastError include the following:

  • ERROR_INSUFFICIENT_BUFFER
  • ERROR_INVALID FLAGS
  • ERROR_INVALID_PARAMETER

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winnls.h   Coreloc.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

GetCurrencyFormat, NUMBERFMT

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.