DriveType Property

Applies to TestComplete 14.80, last modified on April 20, 2021

Description

Use the DriveType property to determine whether the given drive is fixed, removable, network, CD-ROM and so on.

Declaration

aqDriveInfoObj.DriveType

Read-Only Property Integer
aqDriveInfoObj An expression, variable or parameter that specifies a reference to an aqDriveInfo object

Applies To

The property is applied to the following object:

Property Value

An integer number that can accept one of the following values:

Constant Meaning Description
0 Unknown The drive type cannot be determined.
1 No root dir The root path is invalid; for example, no volume is mounted at the path.
2 Removable The drive has a removable media. This includes all floppy drives.
3 Fixed The drive has a fixed (nonremovable) media. This value includes all hard drives, even those that are removable.
4 Remote Network drives. This includes drives shared anywhere on a network.
5 CDRom The drive is a CD-ROM. No distinction is made between read-only and read/write CD-ROM drives.
6 RamDisk The drive is a block of Random Access Memory (RAM) on the local computer that behaves like a disk drive.

Example

The code below demonstrates how you can obtain the letters of specific drives only, for instance, CD-ROM drives.

JavaScript, JScript

function DriveTypeExample()
{
 var CDRomType = 5;
 colDrives = aqFileSystem.Drives;
 for (i = 0; i != colDrives.Count; i++)
 {
 if (colDrives(i).DriveType == CDRomType)
  Log.Message("The CD-ROM drive is: " + colDrives(i).DriveLetter);
 }
}

Python

def DriveTypeExample():
  CDRomType = 5
  colDrives = aqFileSystem.Drives
  for i in range(0, colDrives.count):
    if colDrives.Item(i).DriveType == CDRomType:
      Log.Message("The CD-ROM drive is: " + colDrives.Item(i).DriveLetter)

VBScript

Sub DriveTypeExample()
  Dim CDRomType, i, colDrives
  CDRomType = 5
  Set colDrives = aqFileSystem.Drives
  For i = 0 to colDrives.Count-1
  If colDrives(i).DriveType = CDRomType Then
   Call Log.Message("The CD-ROM drive is: " + colDrives(i).DriveLetter)
  End If
 Next
End Sub

DelphiScript

function DriveTypeExample;
var i, CDRomType, colDrives: OleVariant;
begin
 CDRomType := 5;
 colDrives := aqFileSystem.Drives;
 for i := 0 to colDrives.Count-1 do
 begin
  if (colDrives.Item(i).DriveType = CDRomType) then
   Log.Message('The CD-ROM drive is: ' + ColDrives.Item(i).DriveLetter);
 end;
end;

C++Script, C#Script

function DriveTypeExample()
{
 CDRomType = 5;
 colDrives = aqFileSystem["Drives"];
 for (i = 0; i != colDrives["Count"]; i++)
 {
 if (colDrives(i)["DriveType"] == CDRomType)
  {
  Log["Message"]("The CD-ROM drive is: " + colDrives(i)["DriveLetter"])
  }
 }
}

See Also

Working With Files From Scripts
GetDriveInfo Method
DriveLetter Property

Highlight search results