网站首页  词典首页

请输入您要查询的函数:

 

术语 getlocaleinfo
释义 GetLocaleInfo
语法:
int GetLocaleInfo(
__in LCID Locale,
__in LCTYPE LCType,
__out LPTSTR lpLCData,
__in int cchData
);
GetLocaleInfo函数
检索信息所指定的区域设置标识符。
注意:对于互操作性的原因,应用程序应更喜欢GetLocaleInfoEx功能GetLocaleInfo,因为微软是对的,而不是新的区域设置的区域设置标识符地区名称的使用迁移。任何应用程序只能在Windows Vista和以后应使用GetLocaleInfoEx运行。
参数
区域设置 [in]
区域设置标识符用来检索信息。您可以使用MAKELCID宏创建一个区域设置标识符或使用下列预定义的值之一。
LOCALE_CUSTOM_DEFAULT
LOCALE_CUSTOM_UI_DEFAULT
LOCALE_CUSTOM_UNSPECIFIED
LOCALE_INVARIANT
LOCALE_SYSTEM_DEFAULT
LOCALE_USER_DEFAULT
LCType [in]
地区信息的检索。为了可能的值,请参阅“在GetLocaleInfo,GetLocaleInfoEx,和SetLocaleInfo LCType参数使用”的区域设置信息常量部分常量。请注意,只有一个区域一条信息可以按次指定。但是,应用程序可以使用的二进制运算符来合并或与其他任何可以不断LOCALE_USE_CP_ACP。
注意:对于GetLocaleInfo,LOCALE_USE_CP_ACP是只对相关的ANSI版本。
该应用程序也可以使用二进制运算符来合并或与其他任何可以不断LOCALE_RETURN_NUMBER。在这种情况下,作为检索的功能,而不是一个字符串的数值。接收缓冲区的值必须至少在一个DWORD值,它是2的长度。
注意它也可以结合任何其他不变LOCALE_NOUSEROVERRIDE。但是,这种持续强烈建议不要使用。它不保证数据的稳定,因为返回的数据仍然可以改变意想不到的方式。
如果LCType设置为LOCALE_IOPTIONALCALENDAR,检索功能仅在第一个备用日历。
注意:要获得所有备用日历,应用程序应使用EnumCalendarInfo。
从Windows Vista开始,您的应用程序不应使用在LCType参数LOCALE_ILANGUAGE避免失败或意外的数据检索。相反,它建议您的应用程序调用GetLocaleInfoEx。
lpLCData [out]
可选。缓冲区指针在本函数检索要求的区域设置信息。这不使用指针,如果cchData设置为0。有关详细信息,请参见备注部分。
cchData [in]
大小,这表明在TCHAR值,数据缓冲区lpLCData。另外,应用程序可以设置为0参数。在这种情况下,该函数不使用lpLCData参数并返回所需的缓冲区大小,包括终止空字符。
返回值
返回的语言环境中检索数据缓冲区的字符数,如果成功,cchData是一个非零值。如果函数成功,cchData不为零,并LOCALE_RETURN_NUMBER指定,返回值是在数据缓冲区检索的整数,也就是为函数或4 ANSI版本的Unicode版本2的大小。如果函数成功与cchData值为0,返回值是所需的大小,在包括一个空字符,字符,为区域数据缓冲区。
该函数返回0,如果没有成功。为了获得更多错误信息,应用程序可以调用GetLastError函数,可以返回以下错误代码之一:
ERROR_INSUFFICIENT_BUFFER。阿提供的缓冲区大小不够大,或者被错误地设置为NULL。
ERROR_INVALID_FLAGS。旗帜提供的值不是有效的。
ERROR_INVALID_PARAMETER。该参数值的任何无效。
备注
这正常检索文本格式的信息。如果信息是一个数字值和LCType值LOCALE_ILANGUAGE或LOCALE_IDEFAULTLANGUAGE,这个函数检索包含十六进制数字的字符串。否则,对数字信息检索的文本是一个十进制数。
有两个例外的规则。首先,应用程序可以通过指定检索在LCType参数LOCALE_RETURN_NUMBER为整数数值。第二个例外是,LOCALE_FONTSIGNATURE行为不同于其他所有区域设置信息常量。应用程序必须提供数据缓冲区至少sizeof(LOCALESIGNATURE)字节。在从函数成功返回,缓冲区填充作为LOCALESIGNATURE结构。
注意:即使LCType参数是LOCALE_FONTSIGNATURE,cchData和函数返回指定仍然TCHAR罪名。伯爵是不同的ANSI和Unicode版本的功能。当应用程序调用的GetLocaleInfo与LOCALE_FONTSIGNATURE仿制,cchData可以安全地指定为sizeof(LOCALESIGNATURE)/ sizeof(TCHAR)。
下面的例子正确处理与非缓冲区大小,文本值:

int ret;
CALID calid;
DWORD value;
ret = GetLocaleInfo( LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE |
LOCALE_RETURN_NUMBER, (LPTSTR)&value, sizeof(value) / sizeof(TCHAR) );
calid = value;
LOCALESIGNATURE LocSig;
ret = GetLocaleInfo( LOCALE_USER_DEFAULT,
LOCALE_FONTSIGNATURE,
(LPWSTR)&LocSig,
sizeof(LocSig) / sizeof(TCHAR) );
这个功能可以自定义区域设置检索数据。数据不能保证从同一计算机到计算机之间或应用程序的运行。如果应用程序必须坚持或传输数据,请参阅使用持久性本地化数据。
在ANSI字符串检索到该函数的ANSI版本从Unicode转换为ANSI基于默认ANSI代码页的区域设置标识符。但是,如果LOCALE_USE_CP_ACP指定的翻译是基于系统的默认ANSI代码页。
当此函数的ANSI版本,是使用一个Unicode只设置标识符,函数可以成功,因为操作系统使用系统代码页。然而,在字符系统代码页未定义出现在一个字符串问号(?)。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinnls.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetLocaleInfoW(Unicode)和GetLocaleInfoA(ANSI)的
参见
国家语言支持
国家语言支持功能
检索和设置区域设置信息
GetLocaleInfoEx
GetSystemDefaultLCID
GetUserDefaultLCID
SetLocaleInfo
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月12号
==英文原文==GetLocaleInfo Function
Retrieves information about a locale specified by identifier.
Note For interoperability reasons, the application should prefer the GetLocaleInfoEx function to GetLocaleInfo 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 GetLocaleInfoEx .
Syntax
int GetLocaleInfo(
__in LCID Locale,
__in LCTYPE LCType,
__out LPTSTR lpLCData,
__in int cchData
);
Parameters
Locale [in]
Locale identifier for which to retrieve information. You can use the MAKELCID macro to create a locale identifier or use one of the following predefined values.
LOCALE_CUSTOM_DEFAULT
LOCALE_CUSTOM_UI_DEFAULT
LOCALE_CUSTOM_UNSPECIFIED
LOCALE_INVARIANT
LOCALE_SYSTEM_DEFAULT
LOCALE_USER_DEFAULT
LCType [in]
The locale information to retrieve. For possible values, see the "Constants Used in the LCType Parameter of GetLocaleInfo, GetLocaleInfoEx, and SetLocaleInfo" section in Locale Information Constants . Note that only one piece of locale information can be specified per call. However, the application can use the binary OR operator to combine LOCALE_USE_CP_ACP with any other allowed constant.
Note For GetLocaleInfo, LOCALE_USE_CP_ACP is relevant only for the ANSI version.
The application can also use the binary OR operator to combine LOCALE_RETURN_NUMBER with any other allowed constant. In this case, the function retrieves the value as a number instead of a string. The buffer that receives the value must be at least the length of a DWORD value, which is 2.
Caution It is also possible to combine LOCALE_NOUSEROVERRIDE with any other constant. However, use of this constant is strongly discouraged. It does not guarantee data stability since the data returned can still change in unexpected ways.
If LCType is set to LOCALE_IOPTIONALCALENDAR , the function retrieves only the first alternate calendar.
Note To get all alternate calendars, the application should use EnumCalendarInfo .
Starting with Windows Vista, your applications should not use LOCALE_ILANGUAGE in the LCType parameter to avoid failure or retrieval of unexpected data. Instead, it is recommended for your applications to call GetLocaleInfoEx .
lpLCData [out]
Optional. Pointer to a buffer in which this function retrieves the requested locale information. This pointer is not used if cchData is set to 0. For more information, see the Remarks section.
cchData [in]
Size, in TCHAR values, of the data buffer indicated by lpLCData. Alternatively, the application can set this parameter to 0. In this case, the function does not use the lpLCData parameter and returns the required buffer size, including the terminating null character.
Return Value
Returns the number of characters retrieved in the locale data buffer if successful and cchData is a nonzero value. If the function succeeds, cchData is nonzero, and LOCALE_RETURN_NUMBER is specified, the return value is the size of the integer retrieved in the data buffer, that is, 2 for the Unicode version of the function or 4 for the ANSI version. If the function succeeds and the value of cchData is 0, the return value is the required size, in characters including a null character, for the locale data buffer.
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 normally retrieves information in text format. If the information is a numeric value and the value of LCType is LOCALE_ILANGUAGE or LOCALE_IDEFAULTLANGUAGE , this function retrieves strings containing hexadecimal numbers. Otherwise, the retrieved text for numeric information is a decimal number.
There are two exceptions to this rule. First, the application can retrieve numeric values as integers by specifying LOCALE_RETURN_NUMBER in the LCType parameter. The second exception is that LOCALE_FONTSIGNATURE behaves differently from all other locale information constants. The application must provide a data buffer of at least sizeof(LOCALESIGNATURE) bytes. On successful return from the function, the buffer is filled in as a LOCALESIGNATURE structure.
Note Even when the LCType parameter is specified as LOCALE_FONTSIGNATURE, cchData and the function return are still TCHAR counts. The count is different for the ANSI and Unicode versions of the function. When an application calls the generic version of GetLocaleInfo with LOCALE_FONTSIGNATURE, cchData can be safely specified as sizeof(LOCALESIGNATURE) / sizeof(TCHAR).
The following examples deal correctly with the buffer size for non-text values:

int ret;
CALID calid;
DWORD value;
ret = GetLocaleInfo( LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE |
LOCALE_RETURN_NUMBER, (LPTSTR)&value, sizeof(value) / sizeof(TCHAR) );
calid = value;
LOCALESIGNATURE LocSig;
ret = GetLocaleInfo( LOCALE_USER_DEFAULT,
LOCALE_FONTSIGNATURE,
(LPWSTR)&LocSig,
sizeof(LocSig) / sizeof(TCHAR) );
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 .
The ANSI string retrieved by the ANSI version of this function is translated from Unicode to ANSI based on the default ANSI code page for the locale identifier. However, if LOCALE_USE_CP_ACP is specified, the translation is based on the system default ANSI code page.
When the ANSI version of this function is used with a Unicode-only locale identifier, the function 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 clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinnls.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesGetLocaleInfoW (Unicode) and GetLocaleInfoA (ANSI)
See Also
National Language Support
National Language Support Functions
Retrieving and Setting Locale Information
GetLocaleInfoEx
GetSystemDefaultLCID
GetUserDefaultLCID
SetLocaleInfo
Send comments about this topic to Microsoft
Build date: 7/12/2009
==原始网址==http://msdn.microsoft.com/en-us/library/dd318101(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:24:15