| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1333 人关注过本帖
标题:如何用代码修改XP系统的日期格式
只看楼主 加入收藏
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
结帖率:85.71%
收藏
已结贴  问题点数:20 回复次数:2 
如何用代码修改XP系统的日期格式
如何用代码修改XP系统的日期格式? 例如:我现在的格式是11-17-2011,我想改为11/17/2011.
搜索更多相关主题的帖子: 如何 XP系统 
2011-11-17 09:25
睿翼
Rank: 3Rank: 3
来 自:广东
等 级:论坛游侠
帖 子:40
专家分:175
注 册:2010-12-13
收藏
得分:20 
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

2011-11-17 11:34
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 2楼 睿翼
太好了,谢谢
2011-11-17 11:37
快速回复:如何用代码修改XP系统的日期格式
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018550 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved