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, fmOpenWrite);
  24.     if(ff==-1)
  25.     {
  26.       Application->MessageBox("打开文件不正确!","提示",MB_OK);
  27.       return;
  28.     }
  29.     D_T=Now();
  30.     DateTimeToSystemTime(D_T,S_T);
  31.     SystemTimeToFileTime(&S_T,&C_T);
  32.     SystemTimeToFileTime(&S_T,&A_T);
  33.     SystemTimeToFileTime(&S_T,&W_T);
  34.     if(SetFileTime((void*)ff,&C_T,&A_T,&W_T))
  35.       Application->MessageBox("修改日期成功!","提示",MB_OK);
  36.     else
  37.       Application->MessageBox("修改日期错误!","提示",MB_OK);
  38.     FileClose(ff);
  39.   }
  40. }
  41. //---------------------------------------------------------------------------
  42.