用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心编程技巧Delphi

FSO系列之六**示例代码之详细代码1

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 20:15:05
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' ShowDriveType
''
'' 目的:
''
'' 生成一个字符串,来描述给定 Drive 对象的驱动器类型。
''
'' 示范下面的内容
''
'' - Drive.DriveType
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function ShowDriveType(Drive)

    Dim S
  
    Select Case Drive.DriveType
    Case DriveTypeRemovable
        S = "Removable"
    Case DriveTypeFixed
        S = "Fixed"
    Case DriveTypeNetwork
        S = "Network"
    Case DriveTypeCDROM
        S = "CD-ROM"
    Case DriveTypeRAMDisk
        S = "RAM Disk"
    Case Else
        S = "Unknown"
    End Select

    ShowDriveType = S

End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' ShowFileAttr
''
'' 目的:
''
'' 生成一个字符串,来描述文件或文件夹的属性。
''
'' 示范下面的内容
''
'' - File.Attributes
'' - Folder.Attributes
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function ShowFileAttr(File) '' File 可以是文件或文件夹

    Dim S
      Dim Attr
    
    Attr = File.Attributes

    If Attr = 0 Then
        ShowFileAttr = "Normal"
        Exit Function
    End If

    If Attr And FileAttrDirectory  Then S = S & "Directory "
    If Attr And FileAttrReadOnly   Then S = S & "Read-Only "
    If Attr And FileAttrHidden     Then S = S & "Hidden "
    If Attr And FileAttrSystem     Then S = S & "System "
    If Attr And FileAttrVolume     Then S = S & "Volume "
    If Attr And FileAttrArchive    Then S = S & "Archive "
    If Attr And FileAttrAlias      Then S = S & "Alias "
    If Attr And FileAttrCompressed Then S = S & "Compressed "

    ShowFileAttr = S

End Function


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' GenerateDriveInformation
''
'' 目的:
''
'' 生成一个字符串,来描述可用驱动器的当前状态。
''
'' 示范下面的内容
''
'' - FileSystemObject.Drives
'' - Iterating the Drives collection
'' - Drives.Count
'' - Drive.AvailableSpace
'' - Drive.DriveLetter
'' - Drive.DriveType
'' - Drive.FileSystem
'' - Drive.FreeSpace
'' - Drive.IsReady
'' - Drive.Path
'' - Drive.SerialNumber
'' - Drive.ShareName
'' - Drive.TotalSize
'' - Drive.VolumeName
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function GenerateDriveInformation(FSO)

    Dim Drives
    Dim Drive
    Dim S

    Set Drives = FSO.Drives

    S = "Number of drives:" & TabStop & Drives.Count & NewLine & NewLine

    '' 构造报告的第一行。
    S = S & String(2, TabStop) & "Drive"
    S = S & String(3, TabStop) & "File"
    S = S & TabStop & "Total"
    S = S & TabStop & "Free"
    S = S & TabStop & "Available"
    S = S & TabStop & "Serial" & NewLine

    '' 构造报告的第二行。
    S = S & "Letter"
    S = S & TabStop & "Path"
    S = S & TabStop & "Type"
    S = S & TabStop & "Ready?"
    S = S & TabStop & "Name"
    S = S & TabStop & "System"
    S = S & TabStop & "Space"
    S = S & TabStop & "Space"
    S = S & TabStop & "Space"
    S = S & TabStop & "Number" & NewLine    

    '' 分隔行。
    S = S & String(105, "-") & NewLine

    For Each Drive In Drives

        S = S & Drive.DriveLetter
        S = S & TabStop & Drive.Path
        S = S & TabStop & ShowDriveType(Drive)
        S = S & TabStop & Drive.IsReady

        If Drive.IsReady Then
            If DriveTypeNetwork = Drive.DriveType Then
                S = S & TabStop & Drive.ShareName
            Else
                S = S & TabStop & Drive.VolumeName
            End If    

            S = S & TabStop & Drive.FileSystem
            S = S & TabStop & Drive.TotalSize
            S = S & TabStop & Drive.FreeSpace
            S = S & TabStop & Drive.AvailableSpace
            S = S & TabStop & Hex(Drive.SerialNumber)

        End If

        S = S & NewLine

    Next  
    
    GenerateDriveInformation = S

End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' GenerateFileInformation
''
'' 目的:
''
'' 生成一个字符串,来描述文件的当前状态。
''
'' 示范下面的内容
''
'' - File.Path
'' - File.Name
'' - File.Type
'' - File.DateCreated
'' - File.DateLastAccessed
'' - File.DateLastModified
'' - File.Size
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function GenerateFileInformation(File)

    Dim S

    S = NewLine & "Path:" & TabStop & File.Path
    S = S & NewLine & "Name:" & TabStop & File.Name
    S = S & NewLine & "Type:" & TabStop & File.Type
    S = S & NewLine & "Attribs:" & TabStop & ShowFileAttr(File)
    S = S & NewLine & "Created:" & TabStop & File.DateCreated
    S = S & NewLine & "Accessed:" & TabStop & File.DateLastAccessed
    S = S & NewLine & "Modified:" & TabStop & File.DateLastModified
    S = S & NewLine & "Size" & TabStop & File.Size & NewLine

    GenerateFileInformation = S

End Function


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' GenerateFolderInformation
''
'' 目的:
''
'' 生成一个字符串,来描述文件夹的当前状态。
''
'' 示范下面的内容
''
'' - Folder.Path
'' - Folder.Name
'' - Folder.DateCreated
'' - Folder.DateLastAccessed
'' - Folder.DateLastModified
'' - Folder.Size
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function GenerateFolderInformation(Folder)

    Dim S

    S = "Path:" & TabStop & Folder.Path
    S = S & NewLine & "Name:" & TabStop & Folder.Name
    S = S & NewLine & "Attribs:" & TabStop & ShowFileAttr(Folder)
    S = S & NewLine & "Created:" & TabStop & Folder.DateCreated
    S = S & NewLine & "Accessed:" & TabStop & Folder.DateLastAccessed
    S = S & NewLine & "Modified:" & TabStop & Folder.DateLastModified
    S = S & NewLine & "Size:" & TabStop & Folder.Size & NewLine

    GenerateFolderInformation = S

End Function

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:2,640.62500 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号