首页/技术开发/内容

VFP中确定驱动器分类的2几种办法

技术开发2023-09-02 阅读()
    在应用程序的设计中,有时我们需要知道用户的驱动器的配置情况,在VFP中有多种方法可以实现,现介绍如下:

    一、通过调用GetDriveType API函数来完成。

    下面的代码就可以检索出系统中所有的驱动器:

    表单的ACTIVATE方法:

        Declare Long GetDriveType In "kernel32" String nDrive

        Dime I, DrvName, DrvType
        For I = 0 To 25
            DrvName = Chr(I + 65) + ":"
            DrvType = GetDriveType(DrvName)
            Do Case
                Case DrvType =  2
                    Print "驱动器" + DrvName + "是一个软盘驱动器"
                Case DrvType = 3
                    Print "驱动器" + DrvName + "是一个硬盘驱动器"
                Case DrvType = 4
                    Print "驱动器" + DrvName + "是一个可移去式驱动器或网络驱动器"
                Case DrvType = 5
                    Print "驱动器" + DrvName + "是一个CD-ROM驱动器"
                Case DRIVE_RAMDISK
                    Print "驱动器" + DrvName + "是一个RAM 盘"
                Case Else
            EndcCase
        Next I

    二、使用FOXTOLLS.FLL中的DriveType函数。

       表单的ACTIVATE方法:

       Set Libriry To FoxTools.FLL

        Dime I, DrvName, DrvType
        For I = 0 To 25
            DrvName = Chr(I + 65) + ":"
            DrvType = DriveType(DrvName)
            Do Case
                Case DrvType =  2
                    Print "驱动器" + DrvName + "是一个软盘驱动器"
                Case DrvType = 3
                    Print "驱动器" + DrvName + "是一个硬盘驱动器"
                Case DrvType = 4
                    Print "驱动器" + DrvName + "是一个可移去式驱动器或网络驱动器"
                Case DrvType = 5
                    Print "驱动器" + DrvName + "是一个CD-ROM驱动器"
                Case DRIVE_RAMDISK
                    Print "驱动器" + DrvName + "是一个RAM 盘"
                Case Else
            EndcCase
        Next I

……

相关阅读