PDA

View Full Version : Setting File Creation Time



Bsbosa.com
07-09-2010, 01:20 PM
I've been trying to put some code together for setting a desired file creation date/time.
I also got introduced to the FILETIME structure (2 DWORD).
DWORD unsigned long 4,294,967,296 (possibles, including zero)

Hopefully I can get a string to be processed and set the file creation date/time.

So these would be the variables for the DWORD:

1 second 100
1 minute 6,000
1 hour 360,000
24 hours 8,640,000
1 year 3,153,600,000


Current resources on MSDN use SystemTime functions, out of fear of guiding someone to fake copyrighted material.

HANDLE File = CreateFile(L"My File.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_WRITE_ATTRIBUTES, NULL);
SetFileTime( File, &CreationTime, NULL, NULL);
CloseHandle(File);