修改文件修改时间的东西

#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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值