Page 1 of 1

API to create a "touch" program

Posted: Mon Jan 05, 2009 1:47 pm
by graves
Hi,
I need to change modification date of a folder and some files. But I dont know any Windows API to do it.

Anyone knows it?
Thanks to all.

Re: API to create a "touch" program

Posted: Mon Jan 05, 2009 1:49 pm
by PB

Posted: Mon Jan 05, 2009 1:58 pm
by graves
Sorry, :oops:
I dont know this command. I will test it to use in a folder.

Thanks PB

Posted: Mon Jan 05, 2009 4:17 pm
by graves
Sorry, again.
It runs fine with a file but IT NOT RUNS with a folder.

I've tried with folder name, with complete path and with "folder\."

Topic subject again "API to change date of a FOLDER".
Anyone?

Posted: Tue Jan 06, 2009 11:43 am
by Shardik
graves wrote:I need to change modification date of a folder
netmaestro has already posted a fine example to change the creation date of a folder via Windows API:
http://www.purebasic.fr/english/viewtopic.php?t=28023

To change the modification date of a folder simply change the following line in netmaestro's example

Code: Select all

SetFileTime_(FolderHandle, @ft, #Null, #Null)
against this line

Code: Select all

SetFileTime_(FolderHandle, #Null, #Null, @ft)
Explanation: the 2nd parameter of the API function SetFileTime() is a pointer to the new creation time, the 4th parameter is a pointer to the new modification time.
Win32.Hlp wrote:The SetFileTime function sets the date and time that a file was created, last accessed, or last modified.

BOOL SetFileTime(

HANDLE hFile, // identifies the file
CONST FILETIME *lpCreationTime, // time the file was created
CONST FILETIME *lpLastAccessTime, // time the file was last accessed
CONST FILETIME *lpLastWriteTime // time the file was last written
);

Posted: Wed Jan 07, 2009 10:09 am
by graves
Thanks Shardik, it runs alright now.