⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.cpp

📁 Get system data and time
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
GetLocalTime(&systime);
AnsiString str=TimeToStr(SystemTimeToDateTime(systime));
Edit1->Text=str;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
GetLocalTime(&systime);
AnsiString str=TimeToStr(SystemTimeToDateTime(systime));
Edit1->Text=str;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
GetLocalTime(&systime);
systime.wHour=Edit2->Text.ToInt();
systime.wMinute=Edit3->Text.ToInt();
SetLocalTime(&systime);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)
{
Close();        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)
{
if (OpenDialog1->Execute()) {
 filename=OpenDialog1->FileName;
 LabeledEdit1->Text=filename;


HANDLE hFile=(HANDLE)FileOpen(filename,fmOpenRead);
GetFileTime(hFile,&ftCreationTime,&ftLastAccessTime,&ftLastWriteTime);
FileTimeToSystemTime(&ftCreationTime,&s);
filetime=""+IntToStr(s.wDay)+"."+IntToStr(s.wMonth)+"."+IntToStr(s.wYear)+"   "+IntToStr(s.wHour)+"."+IntToStr(s.wMinute)+"."+IntToStr(s.wSecond)+"";
LabeledEdit2->Text=filetime;
//filetime=FormatDateTime( "c",FileTimeToDateTime(&ftCreationTime));
//FileInfo+="\nLast Access Time:"+FormatDateTime("c",FileTimeToDateTime(&ftLastAccessTime));
//FileInfo+="\nLast Write Time:"+FormatDateTime("c",FileTimeToDateTime(&ftLastWriteTime));
//Label1->Caption=FileInfo;
FileClose((int) hFile);
//  filetimeto
 }

}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -