Hello,
I want to change the creation, last modified and last viewed date of a file. Can somebody help me with that? I think it can be done with the windows api, but I have no idea how.
MFG,
keeper
Hello,
I want to change the creation, last modified and last viewed date of a file. Can somebody help me with that? I think it can be done with the windows api, but I have no idea how.
MFG,
keeper
Simple example which creates file time.txt with very strange dates.
The SYSTEMTIME struct:
And here's the code:Code:typedef struct _SYSTEMTIME { WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME;
Code:#include <windows.h> int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil){ HANDLE hFile=CreateFile("time.txt",GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); FILETIME created,accessed,modified; SYSTEMTIME sys_created={1601,1,1,1,3,7,9,0},sys_accessed={1704,2,1,2,11,43,12,0}, sys_modified={2962,1,1,8,19,42,40,0}; SystemTimeToFileTime(&sys_created,&created); SystemTimeToFileTime(&sys_accessed,&accessed); SystemTimeToFileTime(&sys_modified,&modified); SetFileTime(hFile,&created,&accessed,&modified); CloseHandle(hFile); return 1; }
"The Internet treats censorship as damage and routes around it." - John Gilmore
Thanks, but where get this file time.txt saved and how does I change the date and time of an existing file. And can you tell me how to call this function int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil). I don't know what parameters to give.
WinMain is like main for windows programs.
http://cboard.cprogramming.com/showthread.php?t=79619