Solved

How can I Check a virtual drive

Posted on 2004-04-06
10
198 Views
Last Modified: 2013-11-15
I Want to ensure :

Is a drive a real (not virtual or device driver) drive? hard disk or cd drive
0
Comment
Question by:khalil_moghaddam
10 Comments
 
LVL 3

Expert Comment

by:SuperUt
ID: 10772259
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
 
LVL 12

Expert Comment

by:esoftbg
ID: 10772310
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
 
LVL 12

Expert Comment

by:esoftbg
ID: 10772320
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 12

Expert Comment

by:esoftbg
ID: 10772459
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
 
LVL 1

Author Comment

by:khalil_moghaddam
ID: 10773705
But This Function can't recognize a virtual drive application linke CloneCd (a burning CD app.) it recognize it az an CD drive
0
 
LVL 1

Author Comment

by:khalil_moghaddam
ID: 10773773
But This Function can't recognize a virtual drive like CloneCd (a burning CD app.) it recognize it az an CD drive
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 10779230
I think this application does a good camouflage of the virtual drive like CloneCd ;-))

emil
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13276138
PAQed with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
VM backup deduplication is a method of reducing the amount of storage space needed to save VM backups. In most organizations, VMs contain many duplicate copies of data, such as VMs deployed from the same template, VMs with the same OS, or VMs that h…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question