2
我有以下代碼: -更改C文件創建日期++在Windows中使用WINDOWS.H 7
int main(int argc, char** argv) {
onelog a;
std::cout << "a new project";
ofstream file("C:\\users\\Lenovo\\Documents\\varuntest.txt", ios::app);//creates a fie
as varuntest.txt
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;
}
現在的問題是它只會改變當我檢查修改日期在文件的屬性中,我需要問如何更改文件的創建日期而不是修改日期。 感謝
請給這個新手
thesystemtime.wDay = 07; //將更改日 thesystemtime.wMonth = 04; //改變月份 thesystemtime.wYear = 2012; //改變一年 u能提出好的建議通過當前系統日期 – gandhigcpp 2012-04-06 10:36:24
@gandhigcpp在我回答另一個不同的問題之前,我是否可以請求您查看您現有的問題(包括這一問題),並在可能的情況下根據[faq]接受最有用的答案。 – 2012-04-06 10:39:42
:我接受了它,但你也可以回覆我在評論 – gandhigcpp 2012-04-06 10:44:55