Scalabium Software |
|
| Knowledge for your independence'. | |
#122: How can I change a creation date/time for some file on disk? |
|
Today I want to show how you can change a datetime of file creation from own application:
function SetDateToFile(const FileName: string; Value: TDateTime): Boolean;
var
hFile: THandle;
begin
Result := False;
try
{open a file handle}
hFile := FileOpen(FileName, fmOpenWrite or fmShareDenyNone);
{if opened succesfully}
if (hFile > 0) then
{convert a datetime into DOS format and set a date}
Result := (FileSetDate(hFile, DateTimeToFileDate(Value)) = 0)
finally
{close an opened file handle}
FileClose(hFile);
end;
end;
To use: This code can be useful in case of application protection - you can store in creation date of some your file a same important value. For example, version of application or date of first start for your trial.
|
|
Copyright© 1998-2025, Scalabium
Software. All rights reserved. |