• Friday, February 28, 2014

    How to detect drive types in Visual Basic 6 (VB6)

    Here is an idea to detect Drive Type in VB6....

    Goto Project Menu -> References
    Tick on Windows Script Host Modal Object (scroll at last to get)
    Click Ok
    Now, Copy this function and paste in your form:

    private function mDriveType(DriveLetter as string)

    dim dType as DriveTypeConst
    dim a As New IWshRuntimeLibrary.FileSystemObject
    dtype = a.drives(DriveLetter).DriveType
    Select Case dType
    Case Removable:
    mDriveType = "Removable Disk"
    Exit Function
    Case Fixed:
    mDriveType = "Hard Disk"
    Exit Function
    Case RamDisk:
    mDriveType = "RAM"
    Case CDRom:
    mDriveType = "CD ROM"
    Case Remote:
    mDriveType = "Network Drive"
    Case UnknownType:
    mDriveType = "Unknown Type"

    End Select
    End Function

    After this you can use this code like this

    msgbox mDriveType("C:")

    Syed Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)


    Post a Comment