Private Sub m_ChangerFichierDateHeure(p_NomCheminFichier As String)
Dim FileDate As SYSTEMTIME
Dim FileName() As String
Dim strFile As String
Dim lngHandle As Long
If InStr(1, p_NomFichier, "\" ) <> 0 Then
' il faut découper la chaine
FileName = Split(p_NomFichier, "\" )
strFile = FileName(UBound(FileName))
End If
FileDate.wDay = Mid(strFile, 5, 2)
FileDate.wHour = Mid(strFile, 8, 2) - 2 ' pasque l'api est bizarre elle compte les heures - 2 !
FileDate.wMilliseconds = 0
FileDate.wMinute = Mid(strFile, 10, 2)
FileDate.wMonth = Mid(strFile, 3, 2)
FileDate.wSecond = Mid(strFile, 12, 2)
FileDate.wYear = Year(Date)
lngHandle = CreateFile(p_NomFichier, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
Call TouchFileTimes(lngHandle, ByVal FileDate)
CloseHandle lngHandle
End Sub |