Solved

How can I Check a virtual drive

Posted on 2004-04-06
10
192 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

By default, Carbonite Server Backup manages your encryption key for you using Advanced Encryption Standard (AES) 128-bit encryption. If you choose to manage your private encryption key, your backups will be encrypted using AES 256-bit encryption.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now