WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time - Timer and Date Functions
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Change Regional Settings Short Date Style

Keywords:  sShortDate

Question:

How do I change the date style in Regional Settings from a 2-digit to a 4-digit year?

Answer:

	format="desired date string"
	Regsetvalue(@REGCURRENT,"Control Panel\International[sShortDate]",Format)
And here's some more...
  1. Maybe update the registry and ini files then broadcast a WM_TIMECHANGE message...as in...
    	wmtimechange=30 ; WM_TIMECHANGE = 0x1E
    	IntControl(23, -1, wmtimechange, 0, 0)
    

    Use the names you would have used for the WIN.INI file.

    Be sure to update BOTH the WIN.INI file and the registry.

    This entry is in the WIN.INI file, under [Intl] section head and the keyname, sShortDate. To change it to 4-digit year:

    	IniWrite("Intl", "sShortDate", "MM/dd/yyyy")
    	IniWrite("","","")  ; broadcasts a Msg to Windows that WIN.INI has been changed
    

  2. Might also have to fool with IntControl 59 message.

How to Change Regional Settings in Win95 without having to Reboot

Question:

I could use a solution to this as well. The suggestion to update both the registry and the win.ini file was encouraging but IntControl 59 doesn't seem to prod the Control Panel applet to reread the data.

Looking for a way to access the Regional Settings in the Control Panel to change the date format. I can accomplish this by changing registry settings or modifying the WIN.INI; however, in Win95 the system has to be re-booted for the settings to take effect.

I am creating NAL (Novell Application Launcher) objects. When an application is launched, the date format must be YYYY/MM/DD. When the application is closed, the date format must be returned to its original settings. In Win95, the only way I have found to accomplish this without having to re boot is to manually make the changes in the Control Panel. I am looking WinBatch function that will allow me to make this change without having to re boot. I welcome any suggestions.

Answer:

Okay. This works on my Windows 95c (osr2.5) system. Woot. Same problems as before may apply. I'll take applause, USA currency, etc.



;check - Locale Information

kernel = (StrCat(DirWindows(1),"kernel32.dll"))
;LOCALE_SYSTEM_DEFAULT Default system locale. 
;LOCALE_USER_DEFAULT Default user locale. 
;LOCALE_NEUTRAL Default language–neutral locale. 
LOCALE_SLONGDATE = 32
LANG_NEUTRAL = 0
LANG_ENGLISH = 9
Locale_System_Default = Lang_Neutral
Locale_User_Default = LANG_NEUTRAL
;Gosub LocaleDefs
GetLocale = Locale_User_Default
Gosub GetLongDate
SetLocale = Locale_User_Default
Gosub SetLongDate
GetLocale = Locale_User_Default
Gosub GetLongDate
EXIT

:GetLongDate
cchData = DllCall(Kernel, long:"GetLocaleInfoA", long:GetLocale,
long:LOCALE_SLONGDATE,long:0, long:0)
if cchData == 0
Message("GetLocaleInfo failure", "Didn't return length of buffer
needed")
Exit
endif
lpLCData = BinaryAlloc(cchData)
result = DllCall(Kernel, long:"GetLocaleInfoA", long:GetLocale,
long:LOCALE_SLONGDATE,lpbinary:lpLCData, long:cchData)
message("result is", result)
BinaryEODSet(lpLCData, result)
slongdate = BinaryPeekStr(lpLCData, 0, result)
message("slongdate is", slongdate)
;ylen = strIndexWild(slongdate, "mmmm", 1) ;err?? doesn't seem to work
as advertised for y. works for d! end of string thing? m is weird too
;message("number of ys", ylen)
ypos = StrIndexNC(slongdate, "y", 1, @fwdscan)
ys = StrSub(slongdate, ypos, result - ypos + 1)
message("ys = ", ys)
BinaryFree(lpLCData)
Return

;SET new value!
:SetLongDate
Select @True
case ys == "yy"
slongdate = StrReplace(slongdate, "yy", "yyyy")
Break
case ys == "yyyy"
slongdate = StrReplace(slongdate, "yyyy", "yy")
Break
EndSelect
message("trying to change to", slongdate)
cchData = StrLen(slongdate) + 1
lpLCData = BinaryAlloc(cchData)
BinaryPokeStr(lpLCData, 0, slongdate)
BinaryPoke(lpLCData, cchData-1, 0)
result = DllCall(Kernel, long:"SetLocaleInfoA", long:SetLocale,
long:LOCALE_SLONGDATE,lpbinary:lpLCData)
message("result is", result)
BinaryFree(lpLCData)
Return

Article ID:   W14308
Filename:   Change Regional Long and Short Date Style.txt
File Created: 2001:01:09:12:30:24
Last Updated: 2001:01:09:12:30:24