⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileinfo.txt

📁 封装Windows文件句柄程序
💻 TXT
字号:
========================================================================
FileInfo component Version 1.0.0409.1997
   for Delphi 32-bit and C++Builder
Author: Sajan Thomas
Created on: April 4, 1997
Last Modified: April 9, 1997
Copyright 1997 Sajan Thomas
Author's e-mail: Sajan.Thomas@na.manpower.com
May all glory be to God.
========================================================================

This Delphi component is still distributed as freeware!
However, I would like to hear from you.  Send me your comments/suggestions
for improvement etc.  I will try to incorporate them into this component.
The software is provided as is, without any warranty whatsoever.
If you would like the source code, please get in touch with me directly,
indicating whether you are developing for commercial purposes or not, etc.

What is NEW!!
 (1).  If a file does not exist, the date returned is 01/01/0001
 (2).  the LastAccess date returned correctly reflects the last access to the file.
     (In the original, it was always showing the date the program was run!)
 (3).  A new method (called VersionString) that can be used to access
    any Version String resource in a file.
    e.g. VersionString['Comments'] returns any Comments entered into the resource file.
    You know what this means....  Now you can go crazy with custom version strings...!
    e.g. VersionString['Dedication']
         VersionString['MothersName'].....!!!!




I have tested the component in Delphi, on a machine running Windows NT 4.0

Installation
   Install the component via the menu Component|Install and then choose Add.
   Point to the location where you copied the file FileInfo.DCU.
   That is it!  You will have the component installed on your 'Additional' page
   of the component palette.

What does the component do?
   FileInfo is a very simple component that accesses the following
   information for a given file:
      Version Information (e.g. 2.04.1997.03)
      CompanyName, ProductName, ProductVersion etc..
      Date of Last Write to the file
      Date of Creation of the file
      Date of Last Access to the file
    For complete list, see sample code below!

The last three pieces will work under NTFS, FAT etc.
I have also tested the component using UNC paths.
(e.g. \\Server\Volume\directory\FileName)
I tested it on an NT Server and a Novell Netware Server.
The UNC Path did not work when running in Windows95, but worked in WinNT.
In order for the UNC Path to work under WinNT, you will need to preface the
filename with the string '\\?\UNC\'.  i.e. the complete path would become
something like '\\?\UNC\Server_Name\Share_Name\Directory_Name\FileName'

Long file names are supported.  As a matter of fact, if you need paths
that are longer than MAX_PATH size, then preface the path string
with '\\?\'

Usage:
  Drop the component onto a form, and set the filename property.
  At run time, you can access the properties as follows:
       (Assuming the component is named FileInfo1, and you have 4 TEdit
         components on your form to hold the info)
-------------- Begin Sample Code----------------
  FileInfo1.FileName := Application.ExeName;
  With FileInfo1 do
   begin
    Edit1.Text := FormatDateTime('c', DateInfo.Creation);
    Edit2.Text := FormatDateTime('c', DateInfo.LastAccess);
    Edit3.Text := FormatDateTime('c', DateInfo.LastWrite);
    Edit4.Text := VersionInfo.  FileVersion;
    Edit5.Text := VersionInfo.  CompanyName;
    Edit6.Text := VersionInfo.  FileDescription;
    Edit7.Text := VersionInfo.  InternalName;
    Edit8.Text := VersionInfo.  LegalCopyright;
    Edit9.Text := VersionInfo.  OriginalFilename;
    Edit10.Text := VersionInfo. ProductName;
    Edit11.Text := VersionInfo. ProductVersion;
    Edit12.Text := VersionInfo. VersionString['Comments'];
    Edit13.Text := VersionInfo. VersionString['Dedication'];
   end;
-------------- End Sample Code--------------------

The class structures for TFileInfo, and the dependents TFileDateInfo
and TFileVersionInfo are as follows:
-----------------
  TFileDateInfo = Class
   public
    property LastAccess : TDateTime;
    property LastWrite : TDateTime;
    property Creation : TDateTime;
  end;

  TFileVersionInfo = Class
   public
    property FileVersion : String;
    property CompanyName : String;
    property FileDescription : String;
    property InternalName : String;
    property LegalCopyright : String;
    property OriginalFilename : String;
    property ProductName : String;
    property ProductVersion : String;
    property VersionString[StringName : String] : String;  {<--- NEW}
  end;

 TFileInfo = class
  published
   property FileName : String;
  Public
   Property DateInfo : TFileDateInfo;
   Property VersionInfo : TFileVersionInfo;
   Constructor Create(AOwner : TComponent);
 end;
------------------


As you can see, the dates are provided in TDateTime format, and the version
is provided as a string.   All you need to do is set the FileName property.
The component does the rest for you!

Possible uses:
 (1).  In an About box, to display the version of your program. All you have to
   do is, keep the resource file accurate.
 (2). In an installation program, to check for file dates and versions before
   overwriting an existing file.
 (3).  Something else that is creative...!!

Enjoy!

Sajan.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -