Public Function GestLastBackupDate() As String
Dim i As Long
Dim t As New Tprocess
Dim TmpFile As String
Dim Tmp As String
On Error Resume Next
TmpFile = Direxe & "abat.bat"
i = OpenUnFileEcriture(TmpFile)
Print #i, "c:"
Print #i, "cd " & Chr(34) & "c:\Program Files\UrBackup\" & Chr(34)
Print #i, "UrBackupClient_cmd.exe status>" & Chr(34) & Direxe & "lastdate.txt" & Chr(34)
Close #i
Shell TmpFile, vbHide
doevents
i = OpenUnFile(Direxe & "lastdate.txt")
If i > 0 Then
On Error Resume Next
While Not EOF(i)
Line Input #i, Tmp
If InStr(1, Tmp, "last_backup_time", vbTextCompare) > 0 Then
Tmp = GetParam(Tmp, 2, ":")
Tmp = Replace(Tmp, ",", "", 1, , vbTextCompare)
Tmp = Replace(Tmp, Chr(34), "", 1, , vbTextCompare)
GestLastBackupDate = ConvertUnixTimeStampToDateTime(Tmp)
End If
Wend
Close #i
End If
On Error GoTo 0
End Function
Function ConvertToUnixTimeStamp(input_datetime) 'As String
Dim d
d = CDate(input_datetime)
ConvertToUnixTimeStamp = CStr(DateDiff("s", "01/01/1970 00:00:00", d))
End Function
Function ConvertUnixTimeStampToDateTime(input_unix_timestamp) 'As String [regular datetime]
ConvertUnixTimeStampToDateTime = CStr(DateAdd("s", input_unix_timestamp, "01/01/1970 00:00:00"))
End Function
Public Function Direxe() As String
Direxe = App.Path
If Right(Direxe, 1) <> "\" Then
Direxe = Direxe + "\"
End If
End Function
Public Function OpenUnFileEcriture(ByVal UnFichierAuPif As String, Optional ByRef ErrMess As String) As Long
Dim retour As Long
Dim Last As Long
retour = FreeFile
On Error Resume Next
Err = 0
Open UnFichierAuPif For Output As #retour
ErrMess = UnFichierAuPif & "=>" & Err.Description & ":" & Err.Number
Last = Err.Number
If Err.Number > 0 Then
retour = 0
End If
Err = 0
On Error GoTo 0
OpenUnFileEcriture = retour
End Function
Public Function OpenUnFile(ByVal UnFichierAuPif As String, Optional ByRef ErrMsg As String) As Long
Dim retour As Long
retour = FreeFile
On Error Resume Next
Err = 0
Open UnFichierAuPif For Input As #retour
If Err > 0 Then
If Not IsMissing(ErrMsg) Then
ErrMsg = Err.Number & ":" & Err.Description
End If
retour = 0
End If
Err = 0
On Error GoTo 0
OpenUnFile = retour
End Function