sudhi_75
May 6th, 2001, 11:03 AM
Hi,
Friends, can u please let me the know the API through which i can change the System Date Format.
Thanks & regards,
Sudhakara.T.P.
Cakkie
May 7th, 2001, 04:30 AM
This is done in the registry, alter the following keys
HKEY_CURRENT_USER\Control Panel\International\sShortDate
HKEY_CURRENT_USER\Control Panel\International\sLongDate
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
sudhi_75
May 7th, 2001, 06:01 AM
Hi,
thanks & regards,
sudhi.
Iouri
May 7th, 2001, 07:17 AM
'The Win32 API includes native functions that
'allow you To change a file's properties, such as time and date, without a
'third-party DLL.
Option Explicit
'
Private Type FILETIME
dwLowDate As Long
dwHighDate As Long
End Type
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMillisecs As Integer
End Type
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const GENERIC_WRITE = &H40000000
Private Const OPEN_EXISTING = 3
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function CreateFile Lib "kernel32" _
Alias "CreateFileA" (ByVal lpFileName As String, _
ByVal dwDesiredAccess As Long, ByVal dwShareMode _
As Long, ByVal lpSecurityAttributes As Long, ByVal _
dwCreationDisposition As Long, ByVal _
dwFlagsAndAttributes As Long, ByVal hTemplateFile _
As Long) As Long
Private Declare Function LocalFileTimeToFileTime Lib _
"kernel32" (lpLocalFileTime As FILETIME, lpFileTime _
As FILETIME) As Long
Private Declare Function SetFileTime Lib "kernel32" _
(ByVal hFile As Long, ByVal MullP As Long, ByVal _
NullP2 As Long, lpLastWriteTime As FILETIME) As Long
Private Declare Function SystemTimeToFileTime Lib _
"kernel32" (lpSystemTime As SYSTEMTIME, lpFileTime _
As FILETIME) As Long
Sub Main()
Call SetFileDate("c:\autoexec.bat", "10/16/96 12:30 pm")
End Sub
Sub SetFileDate(sFileName As String, sDate As String)
Dim hFile As Long
Dim lResult As Long
Dim udtSysTime As SYSTEMTIME
Dim udtFileTime As FILETIME
Dim udtLocalTime As FILETIME
With udtSysTime
.wYear = Year(sDate)
.wMonth = Month(sDate)
.wDay = Day(sDate)
.wDayOfWeek = WeekDay(sDate) - 1
.wHour = Hour(sDate)
.wMinute = Minute(sDate)
.wSecond = Second(sDate)
End With
lResult = SystemTimeToFileTime(udtSysTime, _
udtLocalTime)
lResult = LocalFileTimeToFileTime(udtLocalTime, _
udtFileTime)
hFile = CreateFile(sFileName, GENERIC_WRITE, _
FILE_SHARE_READ _
Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, _
0, 0)
lResult = SetFileTime(hFile, ByVal 0&, ByVal 0&, _
udtFileTime)
Call CloseHandle(hFile)
End Sub
Iouri Boutchkine
iouri@hotsheet.com