如何用代码修改XP系统的日期格式
如何用代码修改XP系统的日期格式? 例如:我现在的格式是11-17-2011,我想改为11/17/2011.
Private Const LOCALE_STIMEFORMAT = &H1003
Private Const LOCALE_SSHORTDATE = &H1F
Private Const WM_SETTINGCHANGE = &H1A
Private Const HWND_BROADCAST = &HFFFF&
Private Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Sub Form_Load()
Dim dwLCID As Long, i As Long
Dim lpLCData As String * 255, cchData
cchData = Len(lpLCData)
dwLCID = GetSystemDefaultLCID()
i = SetLocaleInfo(dwLCID, LOCALE_SSHORTDATE, "yyyy-MM-dd") '设置短日期格式
PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
i = SetLocaleInfo(dwLCID, 32, "yyyy-MM-dd") '设置长日期格式
PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
i = SetLocaleInfo(dwLCID, LOCALE_STIMEFORMAT, "HH:mm:ss") '设置时间格式
PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
End Sub