* Begin code to read system short date format *
*
* Setup declaration and parameters
Declare INTEGER GetLocaleInfo in Win32API LONG Locale, ;
LONG LCType, STRING @LpLCData, INTEGER cchData
* GetSystemDefaultLCID retrieves the system default locale identifier
Declare LONG GetSystemDefaultLCID in Win32API
Declare SetLocaleInfo in Win32API LONG Locale, LONG LCType, ;
STRING @LpLCData
dwLCID = GetSystemDefaultLCID()
Locale = 2048 && For English language.
LpLCData = space(255) && Address of buffer information.
cchData = LEN(LpLCData) && Size of buffer, LpLCData.
nretval = 0 && Number returned from API call.
cShortdate= "" && Hold original short date format.
* Get version, VFP 5 uses Hexadecimal & decimal, VFP 3 only uses decimal
IF "3.00"$VERSION()
LCType = 31 && Type of information. Decimal 31 for short date.
ELSE
LCType = 0x1f && Type of information. Hex 1f for short date.
ENDIF
* Obtain short date format
nretval = GetLocaleInfo(Locale, LCType, @LpLCData, cchData)
If nretval = 0 Then
=MessageBox ("Could not get information.")
Else
=MessageBox (LpLCData, 32, "Short Date Format")
cShortdate = LpLCData && Store original date format.
EndIf
* Variable for new short date format
cNewshortdate = "MM/dd/yy" && Short date style copied from
&& Control Panel.
setdate = SetLocaleInfo(dwLCID, LCType, cNewshortdate)
* Reread the system short date to see change
nretval = GetLocaleInfo(Locale, LCType, @LpLCData, cchData)
=MessageBox (LpLCData, 32, "Updated short Date Format")
* Now reset date to previous format
cNewshortdate = cShortdate
setdate = SetLocaleInfo(dwLCID, LCType, cNewshortdate)
* Verify date is in original format
nretval = GetLocaleInfo(Locale, LCType, @LpLCData, cchData)
=MessageBox (LpLCData, 32, "")
* End of code
=MessageBox (LpLCData, 32, "")