SetFileTime函数问题
#include <windows.h>#include <iostream.h>
#include <stdlib.h>
#include <stdio.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");
}
if(!SetFileTime(hFile, (LPFILETIME) NULL, (LPFILETIME) NULL, &ft1))
{
cout << "error: " <<GetLastError()<<endl;
}
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;
}上面的代码运行后出来以后的错误号
我查看了下:
错误号 ERROR_INVALID_PARAMETER 87 是:The parameter is incorrect.
怎么使参数错误呢 》》奇怪