FileType Property

Applies to TestComplete 15.42, last modified on September 08, 2022

Description

The FileType property allows you to determine the general type of the file: an executable, a DLL, a font and so on.

Declaration

aqFileVersionInfoObj.FileType

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

Applies To

The property is applied to the following object:

Property Value

One of the following constants defined in the Win32API object:

Constant Value Description
VFT_UNKNOWN 0 Unknown file type.
VFT_APP 1 An executable file.
VFT_DLL 2 A dynamic-link library (DLL).
VFT_DRV 3 A device driver. Use the FileSubType property to get the driver description.
VFT_FONT 4 A font file. Use the FileSubType property to get the font description.
VFT_VXD 5 A virtual device file. Use the FileSubType property to get the virtual device identifier.
VFT_STATIC_LIB 7 A static-link library.

Example

The following example demonstrates how you can determine the type of a binary file:

JavaScript, JScript

function VersionInfoSample()
{
  var FileName = Sys.OSInfo.WindowsDirectory + "\\notepad.exe";
  var VerInfo = aqFileSystem.GetFileInfo(FileName).VersionInfo;

  Log.Message("File type: " + GetFileTypeStr(VerInfo.FileType));
}

function GetFileTypeStr(FileType)
{
  switch (FileType)
  {
    case VFT_APP : return "Executable";
    case VFT_DLL : return "DLL";
    case VFT_DRV : return "Device driver";
    case VFT_FONT : return "Font";
    case VFT_VXD : return "Virtual device";
    case VFT_STATIC_LIB : return "Static-link library";
    default: return "Unknown";
  }
}

Python

def VersionInfoSample():
  FileName = Sys.OSInfo.WindowsDirectory + "\\notepad.exe"
  VerInfo = aqFileSystem.GetFileInfo(FileName).VersionInfo
  Log.Message("File type: " + GetFileTypeStr(VerInfo.FileType))

def GetFileTypeStr(FileType):
  if FileType == VFT_APP:
    return "Executable"
  elif FileType == VFT_DLL:
    return "DLL"
  elif FileType == VFT_DRV:
    return "Device driver"
  elif FileType == VFT_FONT:
    return "Font"
  elif FileType == VFT_VXD:
    return "Virtual device"
  elif FileType == VFT_STATIC_LIB:
    return "Static-link library"
  else: 
    return "Unknown"

VBScript

Sub VersionInfoSample
  Dim FileName, VerInfo

  FileName = Sys.OSInfo.WindowsDirectory & "\notepad.exe"
  Set VerInfo = aqFileSystem.GetFileInfo(FileName).VersionInfo

  Log.Message "File type: " & GetFileTypeStr(VerInfo.FileType)
End Sub

Function GetFileTypeStr(FileType)
  Select Case FileType
    Case VFT_APP GetFileTypeStr = "Executable"
    Case VFT_DLL GetFileTypeStr = "DLL"
    Case VFT_DRV GetFileTypeStr = "Device driver"
    Case VFT_FONT GetFileTypeStr = "Font"
    Case VFT_VXD GetFileTypeStr = "Virtual device"
    Case VFT_STATIC_LIB GetFileTypeStr = "Static-link library"
    Case Else GetFileTypeStr = "Unknown"
  End Select
End Function

DelphiScript

function GetFileTypeStr(FileType);
begin
  case FileType of
    VFT_APP : Result := 'Executable';
    VFT_DLL : Result := 'DLL';
    VFT_DRV : Result := 'Device driver';
    VFT_FONT : Result := 'Font';
    VFT_VXD : Result := 'Virtual device';
    VFT_STATIC_LIB : Result := 'Static-link library';
  else
    Result := 'Unknown';
  end;
end;

procedure VersionInfoSample;
var FileName, VerInfo;
begin
  FileName := Sys.OSInfo.WindowsDirectory + '\notepad.exe';
  VerInfo := aqFileSystem.GetFileInfo(FileName).VersionInfo;

  Log.Message('File type: ' + GetFileTypeStr(VerInfo.FileType));
end;

C++Script, C#Script

function VersionInfoSample()
{
  var FileName = Sys["OSInfo"]["WindowsDirectory"] + "\\notepad.exe";
  var VerInfo = aqFileSystem["GetFileInfo"](FileName)["VersionInfo"];

  Log["Message"]("File type: " + GetFileTypeStr(VerInfo["FileType"]));
}

function GetFileTypeStr(FileType)
{
  switch (FileType)
  {
    case VFT_APP : return "Executable";
    case VFT_DLL : return "DLL";
    case VFT_DRV : return "Device driver";
    case VFT_FONT : return "Font";
    case VFT_VXD : return "Virtual device";
    case VFT_STATIC_LIB : return "Static-link library";
    default: return "Unknown";
  }
}

See Also

FileSubType Property
OSFile Property

Highlight search results