Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:1k
源码类别:

VC书籍

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11.         : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TForm1::Button1Click(TObject *Sender)
  16. {
  17.   TFileTime C_T,A_T,W_T;
  18.   TSystemTime S_T;
  19.   TDateTime D_T;
  20.   int ff;
  21.   if(OpenDialog1->Execute())
  22.   {
  23.     ff=FileOpen(OpenDialog1->FileName, fmOpenRead);
  24.     if(ff==-1)
  25.     {
  26.       Application->MessageBox("打开文件不正确!","提示",MB_OK);
  27.       return;
  28.     }
  29.     if(GetFileTime((void*)ff,&C_T,&A_T,&W_T))
  30.     {
  31.       FileTimeToSystemTime(&C_T,&S_T);
  32.       D_T=SystemTimeToDateTime(S_T);
  33.       Edit1->Text=D_T.DateTimeString();
  34.       FileTimeToSystemTime(&A_T,&S_T);
  35.       D_T=SystemTimeToDateTime(S_T);
  36.       Edit2->Text=D_T.DateTimeString();
  37.       FileTimeToSystemTime(&W_T,&S_T);
  38.       D_T=SystemTimeToDateTime(S_T);
  39.       Edit3->Text=D_T.DateTimeString();
  40.     }
  41.     else
  42.       Application->MessageBox("获取日期错误!","提示",MB_OK);
  43.     FileClose(ff);
  44.   }
  45. }
  46. //---------------------------------------------------------------------------