API to create a "touch" program

Everything else that doesn't fall into one of the other PB categories.
User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

API to create a "touch" program

Post 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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: API to create a "touch" program

Post by PB »

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

Post by graves »

Sorry, :oops:
I dont know this command. I will test it to use in a folder.

Thanks PB
User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

Post 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?
User avatar
Shardik
Addict
Addict
Posts: 2079
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Post 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
);
User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

Post by graves »

Thanks Shardik, it runs alright now.
Post Reply