您的位置:首页 > 其它

修改文件修改时间的东西

2008-05-30 10:03 281 查看
#include "stdafx.h"
#include "windows.h"
#include "iostream.h"
#include "stdlib.h"
int main(int argc, char* argv[])
{
if (argc == 8)
{
FILETIME ft,ft1;
SYSTEMTIME systime;
int gxm,gxm1,gxm2,gxm3,gxm4,gxm5;
gxm=atoi(argv[7]);
gxm=gxm - 1;
gxm1=atoi(argv[2]);
gxm2=atoi(argv[3]);
gxm3=atoi(argv[4]);
gxm4=atoi(argv[5]);
gxm5=atoi(argv[6]);
systime.wYear = gxm1;
systime.wMonth = gxm2;
systime.wDay = gxm3;
systime.wHour = gxm4;
systime.wMinute = gxm5;
systime.wSecond = gxm; //想要改变秒,必须要少一位
SystemTimeToFileTime(&systime, &ft);
LocalFileTimeToFileTime(&ft,&ft1); //把时间转换UTC
HANDLE hFile;
hFile = CreateFile(argv[1], GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ| FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile== INVALID_HANDLE_VALUE)
{
printf("open't the file[!]...................................error/n");
}
SetFileTime(hFile, (LPFILETIME) NULL, (LPFILETIME) NULL, &ft1);
CloseHandle(hFile);
printf("changed[!]...................................OK/n");
return 0;
}
printf("GXM修改文件最后修改日期工具/n");
cout << "文件使用方法为:"<<endl;
cout << "/t" << argv[0] << " path year month Day Hour Minute Second"<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: