Das habe ich im Netz zum Setzen des Dateidatums gefunden:
1. https://docs.microsoft.com/de-de/window ... -file-time
Converting a time_t Value to a File Time
The time functions included in the C run-time use the time_t type to represent the number of seconds elapsed since midnight, January 1, 1970. The following example converts a time_t value to a file time, using the Int32x32To64 function (C+):
Code: Select all
#include <windows.h>
#include <time.h>
void TimetToFileTime( time_t t, LPFILETIME pft )
{
LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD) ll;
pft->dwHighDateTime = ll >>32;
}
2. https://msdn.microsoft.com/de-de/librar ... s.85).aspx
FILETIME structure
Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
Code: Select all
typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME, *PFILETIME;
3. https://docs.microsoft.com/de-de/window ... rrent-time
Changing a File Time to the Current Time
The following example sets the last-write time for a file to the current system time using the SetFileTime function.
The NTFS file system stores time values in UTC format, so they are not affected by changes in time zone or daylight saving time. The FAT file system stores time values based on the local time of the computer.
The file must be opened with the CreateFile function using FILE_WRITE_ATTRIBUTES access.
Code: Select all
#include <windows.h>
// SetFileToCurrentTime - sets last write time to current system time
// Return value - TRUE if successful, FALSE otherwise
// hFile - must be a valid file handle
BOOL SetFileToCurrentTime(HANDLE hFile)
{
FILETIME ft;
SYSTEMTIME st;
BOOL f;
GetSystemTime(&st); // Gets the current system time
SystemTimeToFileTime(&st, &ft); // Converts the current system time to file time format
f = SetFileTime(hFile, // Sets last-write time of the file
(LPFILETIME) NULL, // to the converted current system time
(LPFILETIME) NULL,
&ft);
return f;
}
4. https://docs.microsoft.com/en-us/window ... etfiletime
SetFileTime function
Sets the date and time that the specified file or directory was created, last accessed, or last modified.
Code: Select all
BOOL SetFileTime(
HANDLE hFile,
const FILETIME *lpCreationTime,
const FILETIME *lpLastAccessTime,
const FILETIME *lpLastWriteTime
);
5. https://docs.microsoft.com/de-de/window ... reatefilea
CreateFileA function
Creates or opens a file or I/O device. The most commonly used I/O devices are as follows: file, file stream, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, and pipe. The function returns a handle that can be used to access the file or device for various types of I/O depending on the file or device and the flags and attributes specified.
To perform this operation as a transacted operation, which results in a handle that can be used for transacted I/O, use the CreateFileTransacted function.
Code: Select all
HANDLE CreateFileA(
LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
);
...so, alles schön in C+-Syntax, die ich nicht in AHK adaptieren kann. Gibt es hier jemanden, der da durchblickt und eine AHK-Funktion bauen kann, mit der ich das Datum einer Datei verändern kann? Idealerweise ähnlich der AHK-Funktion FileSetTime (M = Zeitpunkt der letzten Änderung / C = Zeitpunkt der Erstellung / A = Zeitpunkt des letzten Zugriffs), bei der ich die gewünschte Zeit "einfach" mit "TT.MM.JJJJ hh:mm:ss" übergeben kann.
Danke schon mal im Voraus.
HG - Lucky Joe