niedziela, 23 lipca 2023

Time file information - class C++ Builder

 



class time_File
{
private:
TSearchRec modification;
TSystemTime d1,t1,d2,t2;
AnsiString FileN;
public:
time_File(AnsiString name);
AnsiString last_Modfication();
AnsiString create_File();
AnsiString last_Access();

};

time_File::time_File(AnsiString name)
{
FileN=name;
FindFirst(FileN,faAnyFile,modification);
FindClose(modification);
}
AnsiString time_File::last_Modfication()
{

return  (AnsiString) DateTimeToStr(FileDateToDateTime(modification.Time));
}

AnsiString time_File::create_File()
{
FileTimeToSystemTime(&(modification.FindData.ftCreationTime),&d1);
SystemTimeToTzSpecificLocalTime(NULL,&d1,&t1);
return (AnsiString) DateTimeToStr(SystemTimeToDateTime(t1));
}
AnsiString time_File::last_Access()
{
FileTimeToSystemTime(&(modification.FindData.ftLastAccessTime),&d2);
SystemTimeToTzSpecificLocalTime(NULL,&d2,&t2);
return (AnsiString) DateTimeToStr(SystemTimeToDateTime(t2));

}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  AnsiString name_Project=Application->ExeName;
  time_File info_File(name_Project);
  Label4->Caption=name_Project;
  Label1->Caption="Last modification: "+info_File.last_Modfication();
  Label2->Caption="Create time: "+info_File.create_File();
  Label3->Caption="Last access time: "+info_File.last_Access();
}








                

Brak komentarzy:

Prześlij komentarz