|
3#
楼主 |
发表于 2019-5-23 10:57:53
|
只看该作者
Option Compare Database
Public Const LOCALE_STIMEFORMAT = &H1003
Public Const LOCALE_SSHORTDATE = &H1F
Public Const WM_SETTINGCHANGE = &H1A
Public Const HWND_BROADCAST = &HFFFF&
Const SPI_SETDESKWALLPAPER = 20
Const SPIF_SENDCHANGE = &H2
Public Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
Public 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
Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Public 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
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Public Sub setdateformat()
Dim dwLCID As Long, i As Long
Dim lpLCData As String * 255, cchData
cchData = Len(lpLCData)
dwLCID = GetSystemDefaultLCID()
i = SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, "yyyy-MM-dd")
i = SetLocaleInfo(dwLCID, LOCALE_STIMEFORMAT, "hh:mm:ss") '设置时间格式
PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
SystemParametersInfo SPI_SETDESKWALLPAPER, 0, "", SPIF_SENDCHANGE
Debug.Print Time
End Sub
这是网上找到的可以修改系统日期和时间格式的代码,只是修改后时间后面带着上午和下午,如何能去掉啊?
|
|