SetLocaleInfo This function sets an item of locale information. It does so by making an entry in the process portion of the locale table. This setting only affects the user override portion of the locale settings; it does not set the system defaults. BOOL SetLocaleInfo( LCID Locale, LCTYPE LCType, LPWTSTR lpLCData ); Parameters Locale [in] Specifies the locale whose information the function will set. The locale provides a context for the string mapping or sort key generation. An application can use the MAKELCID macro to create a locale identifier. LCType [in] Specifies the type of locale information to be set by the function. Note that only one LCTYPE may be specified per call. Not all LCTYPE values are valid; see the list of valid LCTYPE values in the following Res section. lpLCData [in] Pointer to a null-terminated string that contains the locale information the function will set. The information must be in the specified LCTYPE's particular format. Return ValuesNonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError. Possible values for GetLastError include the following: ERROR_INVALID_ACCESS ERROR_INVALID_FLAGS ERROR_INVALID_PARAMETER ResThe following LCTYPE values are valid for this function:LOCALE_ICALENDARTYPE LOCALE_SDATE LOCALE_ICURRDIGITS LOCALE_SDECIMAL LOCALE_ICURRENCY LOCALE_SGROUPING LOCALE_IDIGITS LOCALE_SLIST LOCALE_IFIRSTDAYOFWEEK LOCALE_SLONGDATE LOCALE_IFIRSTWEEKOFYEAR LOCALE_SMONDECIMALSEP LOCALE_ILZERO LOCALE_SMONGROUPING LOCALE_IMEASURE LOCALE_SMONTHOUSANDSEP LOCALE_INEGCURR LOCALE_SNEGATIVESIGN LOCALE_INEGNUMBER LOCALE_SPOSITIVESIGN LOCALE_IPAPERSIZE LOCALE_SSHORTDATE LOCALE_ITIME LOCALE_STHOUSAND LOCALE_S1159 LOCALE_STIME LOCALE_S2359 LOCALE_STIMEFORMAT LOCALE_SCURRENCY LOCALE_SYEARMONTH Windows CE versions 1.0 through 2.01 do not support the LOCALE_IPAPERSIZE LCTYPE value.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.
var str: string; begin str := 'yy-d-M'; { yy-d-M d-yy-M M-d-yy yy-M-d yyyy-M-d } if SetLocaleInfoa(LOCALE_SYSTEM_DEFAULT, LOCALE_SLONGDATE, PChar(str)) then begin showmessage('更改日期格式成功'); SendMessageA(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0); end; end;
This function sets an item of locale information. It does so by making an entry in the process portion of the locale table. This setting only affects the user override portion of the locale settings; it does not set the system defaults. BOOL SetLocaleInfo(
LCID Locale,
LCTYPE LCType,
LPWTSTR lpLCData );
Parameters Locale
[in] Specifies the locale whose information the function will set. The locale provides a context for the string mapping or sort key generation. An application can use the MAKELCID macro to create a locale identifier.
LCType
[in] Specifies the type of locale information to be set by the function. Note that only one LCTYPE may be specified per call. Not all LCTYPE values are valid; see the list of valid LCTYPE values in the following Res section.
lpLCData
[in] Pointer to a null-terminated string that contains the locale information the function will set. The information must be in the specified LCTYPE's particular format.
Return ValuesNonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError. Possible values for GetLastError include the following: ERROR_INVALID_ACCESS
ERROR_INVALID_FLAGS
ERROR_INVALID_PARAMETER
ResThe following LCTYPE values are valid for this function:LOCALE_ICALENDARTYPE LOCALE_SDATE
LOCALE_ICURRDIGITS LOCALE_SDECIMAL
LOCALE_ICURRENCY LOCALE_SGROUPING
LOCALE_IDIGITS LOCALE_SLIST
LOCALE_IFIRSTDAYOFWEEK LOCALE_SLONGDATE
LOCALE_IFIRSTWEEKOFYEAR LOCALE_SMONDECIMALSEP
LOCALE_ILZERO LOCALE_SMONGROUPING
LOCALE_IMEASURE LOCALE_SMONTHOUSANDSEP
LOCALE_INEGCURR LOCALE_SNEGATIVESIGN
LOCALE_INEGNUMBER LOCALE_SPOSITIVESIGN
LOCALE_IPAPERSIZE LOCALE_SSHORTDATE
LOCALE_ITIME LOCALE_STHOUSAND
LOCALE_S1159 LOCALE_STIME
LOCALE_S2359 LOCALE_STIMEFORMAT
LOCALE_SCURRENCY LOCALE_SYEARMONTH Windows CE versions 1.0 through 2.01 do not support the LOCALE_IPAPERSIZE LCTYPE value.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.
str: string;
begin
str := 'yy-d-M';
{
yy-d-M
d-yy-M
M-d-yy
yy-M-d
yyyy-M-d
}
if SetLocaleInfoa(LOCALE_SYSTEM_DEFAULT, LOCALE_SLONGDATE, PChar(str)) then
begin
showmessage('更改日期格式成功');
SendMessageA(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
end;
end;