Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

How can I Check a virtual drive

I Want to ensure :

Is a drive a real (not virtual or device driver) drive? hard disk or cd drive
0
khalil_moghaddam
Asked:
khalil_moghaddam
1 Solution
 
SuperUtCommented:
In the Windows unit you'll find
function GetDriveType(lpRootPathName: PChar): UINT; stdcall;

The result is one of these:
DRIVE_UNKNOWN  The drive type cannot be determined.
DRIVE_NO_ROOT_DIR  The root path is invalid. For example, no volume is mounted at the path.
DRIVE_REMOVABLE  The disk can be removed from the drive.
DRIVE_FIXED  The disk cannot be removed from the drive.
DRIVE_REMOTE  The drive is a remote (network) drive.
DRIVE_CDROM  The drive is a CD-ROM drive.
DRIVE_RAMDISK  The drive is a RAM disk.

Hope this does it.
0
 
esoftbgCommented:
unit Unit_Q_20946070;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm_CD = class(TForm)
    Btn_Scan_Devices: TButton;
    Memo_Devices: TMemo;
    procedure Btn_Scan_DevicesClick(Sender: TObject);
  private  { Private declarations }
  public   { Public declarations }
    procedure Scan_Devices;
  end;

var
  Form_CD: TForm_CD;

implementation

{$R *.dfm}

procedure TForm_CD.Scan_Devices;
var
  C:                           Char;
  DriveType:                   DWORD;
  PCRootPathName:              PChar;
  SDriveType:                  string;
  S:                           string;
begin
  Memo_Devices.Clear;
  try
    for C := 'D' to 'Z' do
    begin
      S := C + ':\';
      PCRootPathName := PChar(S);
      DriveType := GetDriveType(PCRootPathName);
      case DriveType of
        0:                   SDriveType := '???'; // 'The drive type cannot be determined.';
        1:                   SDriveType := 'The root directory does not exist';
        DRIVE_REMOVABLE: SDriveType := 'FDD'; // 'The drive can be removed from the drive.';
        DRIVE_FIXED:         SDriveType := 'HDD'; // 'The disk cannot be removed from the drive.';
        DRIVE_REMOTE:         SDriveType := 'NET'; // 'The drive is a remote (network) drive.';
        DRIVE_CDROM:     SDriveType := 'CDD'; // 'The drive is a CD-ROM drive.';
        DRIVE_RAMDISK:   SDriveType := 'RAM'; // 'The drive is a RAM disk.';
      end;
      if (DriveType>1) then
        Memo_Devices.Lines.Add(S + ' is a ' + SDriveType)
      else
        Memo_Devices.Lines.Add(S + SDriveType);
   end;
  except
    on E : Exception do
      ShowMessage(E.Message);
  end;
end;

procedure TForm_CD.Btn_Scan_DevicesClick(Sender: TObject);
begin
  Scan_Devices;
end;

end.
0
 
esoftbgCommented:
object Form_CD: TForm_CD
  Left = 219
  Top = 114
  Width = 696
  Height = 480
  Caption = 'Form_CD'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Btn_Scan_Devices: TButton
    Left = 24
    Top = 16
    Width = 96
    Height = 25
    Caption = 'Scan Devices'
    TabOrder = 0
    OnClick = Btn_Scan_DevicesClick
  end
  object Memo_Devices: TMemo
    Left = 134
    Top = 14
    Width = 531
    Height = 407
    TabOrder = 1
  end
end
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
esoftbgCommented:
ooops, replace
>    for C := 'D' to 'Z' do
with
    for C := 'A' to 'Z' do (Including FDD)
or
    for C := 'C' to 'Z' do
0
 
khalil_moghaddamAuthor Commented:
But This Function can't recognize a virtual drive application linke CloneCd (a burning CD app.) it recognize it az an CD drive
0
 
khalil_moghaddamAuthor Commented:
But This Function can't recognize a virtual drive like CloneCd (a burning CD app.) it recognize it az an CD drive
0
 
esoftbgCommented:
I think this application does a good camouflage of the virtual drive like CloneCd ;-))

emil
0
 
moduloCommented:
PAQed with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now