Parsi Coders
سورس کد تغییر تاریخ و ساعت سیستم عامل - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: Visual Basic Programming (http://parsicoders.com/forumdisplay.php?fid=39)
+---- انجمن: Visual Basic 6 (http://parsicoders.com/forumdisplay.php?fid=44)
+---- موضوع: سورس کد تغییر تاریخ و ساعت سیستم عامل (/showthread.php?tid=1391)



سورس کد تغییر تاریخ و ساعت سیستم عامل - Amin_Mansouri - 12-30-2011

Simply copy and pase the function into your programe and run the function by typing
SetDateTime at load event or your desired event.
if you want to change your format to any other type just change
"dd-MMM-yyyy" as your desired format.
کد:
Option Explicit

Private Const LOCALE_SDATE = &H1F
Private Const LOCALE_STIMEFORMAT = &H1003

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

-----------------------------------
Public Function SetDateTime() As Boolean

Dim dwLCID As Long

dwLCID = GetSystemDefaultLCID()

If SetLocaleInfo(dwLCID, LOCALE_SDATE, "dd-MMM-yyyy") = False Then
SetDateTime = False
Exit Function
End If

If SetLocaleInfo(dwLCID, LOCALE_STIMEFORMAT, "HH:mm:ss") = False Then
SetDateTime = False
Exit Function
End If

PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0

SetDateTime = True

End Function

'***************end of module****************