Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.11.18;
Скачать: [xml.tar.bz2];

Вниз

Как определить дату и/или время создания каталога?   Найти похожие ветки 

 
Warl   (2002-11-08 23:37) [0]

Как определить дату и/или время создания каталога?


 
Николай Быков   (2002-11-09 02:02) [1]

________________________________________________________________
TSearchRec type
________________________________________________________________
TSearchRec defines file information searched for by FindFirst or FindNext.

Unit

SysUtils

type
TSearchRec = record
Time: Integer;
Size: Integer;
Attr: Integer;
Name: TFileName;
ExcludeAttr: Integer;
FindHandle: THandle;
FindData: TWin32FindData;
end;

Description

The TSearchRec type defines file information searched for by a FindFirst or FindNext function call. If a file is found, the fields of the TSearchRec type parameter are modified to specify the found file.

Attr represents the file attributes of the file. Test Attr against the following attribute constants or values to determine if a file attribe matches the file"s properties.

Constant Value Description

faReadOnly $00000001 Read-only files
faHidden $00000002 Hidden files
faSysFile $00000004 System files
faVolumeID $00000008 Volume ID files
faDirectory $00000010 Directory files
faArchive $00000020 Archive files
faAnyFile $0000003F Any file

Note: The faReadOnly constant has the same name as the enumerated value that is defined by the TFieldAttribute type. If both the SysUtils and the Db units are used in your source files, you must disambiguate by specifying the unit to qualify the use of faReadOnly. That is, write SysUtils.faReadOnly.

To test for an attribute, combine the value of the Attr field with the attribute constant with the and operator. If the file has that attribute, the result will be greater than 0. For example, if the found file is a hidden file, the following expression will evaluate to True: (SearchRec.Attr and faHidden) <> 0.

Time contains the time stamp of the file. It can be converted to a TDateTime value using FileDateToDateTime.

Size contains the size of the file in bytes.

Name contains the base file name, including extension.

FindHandle is an internal handle used to track find state.

FindData contains additional information such as the file creation time, last access time, and both the long and short file names.
________________________________________________________________
FileDateToDateTime function
________________________________________________________________
Converts an OS timestamp value to TDateTime value.

Unit

SysUtils

Category

file management routines

function FileDateToDateTime(FileDate: Integer): TDateTime;

Description

A timestamp is a signed 32-bit integer, used by the OS to record information such as the date and time a file was modified. The precise format of a timestamp depends on the OS. Use FileDateToDateTime to convert a timestamp to a TDateTime value.

For example, use FileDateToDateTime to convert the file timestamp returned by FileGetDate or FileAge to a value that can be used with other VCL routines and properties. You may also need to use FileDateToDateTime to convert the Time field of the TSearchRec record used by the FindFirst and FindNext functions.


 
Almaz   (2002-11-09 03:16) [2]


> Warl (08.11.02 23:37)
> Как определить дату и/или время создания каталога?

Проще говоря:

function GetDirDateTime(const FileName: string): TDateTime;
var
Handle: THandle;
FindData: TWin32FindData;
LocalFileTime: TFileTime;
Temp: Integer;
begin
Result := -1;
Handle := FindFirstFile(PChar(FileName), FindData);
if Handle <> INVALID_HANDLE_VALUE then
begin
Windows.FindClose(Handle);
FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);
if FileTimeToDosDateTime(LocalFileTime, LongRec(Temp).Hi,
LongRec(Temp).Lo) then
begin
Result := FileDateToDateTime(Temp);
Exit;
end;
end;
end;


Удачи.



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2002.11.18;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.45 MB
Время: 0.008 c
4-59515
TankMan
2002-10-07 00:52
2002.11.18
Список запущенных процессов


4-59498
Василий2
2002-10-06 18:16
2002.11.18
Прошу оветить всех знающих...


3-58987
Colonel Isaev
2002-10-28 16:16
2002.11.18
Вопрос по quick report


14-59417
maxim2
2002-10-25 08:47
2002.11.18
Непорали сделать форум по Kylix ?


14-59381
Эльф
2002-10-30 12:53
2002.11.18
SUIPack





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский