// setTime.cpp: defines the entry point for the console application.///
#include
Void usage () {system ("cls.exe"); Printf ("------------------------------- -------------------- / N "" / TSETTIME VER 1.0 ZHOUZHEN [EST], 2005/3/5 / N "" / THTTP: // www .eviloctal.com, [email] zhouzhen@yeah.net [/ email] / n "" / t file time modifier 1.0 "/ n / n" "/ tusage: / tsettime oldfile newfile / n" "/ texample: / tsettime hello.asp eviLOctal.asp / n "" -------------------------------------- ---------------- / n "); exit (0);
INT Main (int Argc, char * argv []) {handle hfileold, hfilenew; filetime display, OLASTWRITETIME
IF (argc! = 3) usage (); else {
hFileOld = CreateFile (argv [1], GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFileOld == INVALID_HANDLE_VALUE) {printf ( "Can not open% s Error:% x / n.", argv [ 1], getLastError ()); exit (1);
hFileNew = CreateFile (argv [2], GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFileNew == INVALID_HANDLE_VALUE) {printf ( "Can not open% s Error:% x / n.", argv [ 2], getLastError ()); exit (2);
GetFileTime (hFileOld, & OCreateTime, & OLastAccessTime, & OLastWriteTime); pCreationTime = & OCreateTime; pLastAccessTime = & OLastAccessTime; pLastWriteTime = & OLastWriteTime; SetFileTime (hFileNew, pCreationTime, pLastAccessTime, pLastWriteTime); CloseHandle (hFileNew); CloseHandle (hFileOld);
Printf ("all is done! Enjoy yourself / n");
} Return 0;}