QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: krovit on July 26, 2021, 12:33:26 pm
-
Maybe it's the timestamp?
On the forum there is very little on the subject, or I do not know what is the keyword to search for.
I don't know...
I would like to change the dates to the file (creation date, last modification, last access).
These values do not seem to exist in "as it is" inside the file and are not available with OPEN BINARY.
Probably are written in another format.
I tried to look for them in UNIX TIME but it does not seem to be the right method.
All this I need for PDF files.
The dates I'm talking about are not metadata (which in PDF files are easily identifiable and editable).
I would like to do with QB64 - if is it possibile - something of what Attribute Changer very good does (https://www.petges.lu)
Any suggestions?
(Sorry, if I knew how to use WinAPI I would probably solve many problems...)
Tank you (beforehand)
-
@krovit There is a way to do this with WinAPI code. I am trying to write up a small sample for you ;)
-
@krovit Here you go. This will make a file called "filetest.txt" and then set the last modified time to my birthdate.
Const GENERIC_READ
= &H80000000 Const GENERIC_WRITE
= &H40000000
Const FILE_ATTRIBUTE_NORMAL
= &H00000080
As _Unsigned Integer wYear
, wMonth
, wDayOfWeek
, wDay
, wHour
, wMinute
, wSecond
, wMilliseconds
Dim As FILETIME modifiedtime
sys.wYear = 1995
sys.wMonth = 12
sys.wDayOfWeek = 6
sys.wDay = 30
hFile
= CreateFile
("filetest.txt", GENERIC_READ
Or GENERIC_WRITE
, 0, 0, CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, 0)If hFile
<> -1 Then 'If the function fails, the file might already exist. hFile
= CreateFile
("filetest.txt", GENERIC_READ
Or GENERIC_WRITE
, 0, 0, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, 0) 'We open the existing file, maybe.
CloseHandle hFile
-
Thank you SpriggsySpriggs!
More than Superman (Spriggsy's youtube Channel) you are Mandrake that from the top hat (WinAPI) always pulls out a rabbit (routine)!...