c语言使用windows.h,在Windows 7中使用windows.h更改C中的文件创建...

我有以下代码:

int main(int argc, char** argv) {

onelog a;

std::cout << "a new project";

//creates a file as varuntest.txt

ofstream file("C:\users\Lenovo\Documents\varuntest.txt", ios::app);

SYSTEMTIME thesystemtime;

GetSystemTime(&thesystemtime);

thesystemtime.wDay = 07;//changes the day

thesystemtime.wMonth = 04;//changes the month

thesystemtime.wYear = 2012;//changes the year

//creation of a filetimestruct and convert our new systemtime

FILETIME thefiletime;

SystemTimeToFileTime(&thesystemtime,&thefiletime);

//getthe handle to the file

HANDLE filename = CreateFile("C:\users\Lenovo\Documents\varuntest.txt",

FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE,

NULL, OPEN_EXISTING,

FILE_ATTRIBUTE_NORMAL, NULL);

//set the filetime on the file

SetFileTime(filename,(LPFILETIME) NULL,(LPFILETIME) NULL,&thefiletime);

//close our handle.

CloseHandle(filename);

return 0;

}

现在的问题是;它只在我检查文件属性时更改修改日期.我需要问;

How to change the file’s creation date instead of the modification

date?

谢谢

请给这个新手一些代码.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值