Solved

Get description of drives on the computer

Posted on 2003-11-26
5
210 Views
Last Modified: 2010-04-05
I have a function that gives me all of the drives in the computer including the remote drives. I need a function that gives me it´s media type (FAT,FAT32,NTFS,etc), it´s path if it´s a remote drive, it´s volume label, and if possible it´s serial number.
0
Comment
Question by:barbalho
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:TheLeader
ID: 9825576
0
 
LVL 17

Accepted Solution

by:
geobul earned 125 total points
ID: 9825622
Hi,

Use GetVolumeInformation API. All you need is there:

procedure DriveInfo(Drive: Char);
var
 x: integer;
 VSize, VFree: int64;
 VLabel, FSys: array[0..$FF] of char;
 SNr, FL, SysFlag: DWord;
begin
  if not(GetVolumeInformation(PChar(Drive+':\'), VLabel, SizeOf(VLabel), @SNr, FL, SysFlag, FSys, SizeOf(FSys)))
    then VLabel := '_None_';
  ShowMessage('VolumeLabel:'+VLabel);
  ShowMessage('FileSystem:'+string(FSys));
  ShowMessage('VolumeNumber:'+IntToStr(SNr));

  // VLabel  = Volume Label
 // SNr     = Serial Number
 // FL      = Max Filename Length
 // SysFlag = Volume Attributes
 // FSys    = File System (FAT / FAT32 / NTFS etc.)

 x := GetDriveType(PChar(Drive+':\'));
 // x       = TDriveType (See above)

 VSize := DiskSize(Ord(UpCase(Drive))-64);
 VFree := DiskFree(Ord(UpCase(Drive))-64);
 // VSize   = Volume Size
 // VFree   = Free space
end;

// usage:
DriveInfo('c');

Regards, Geo
0
 
LVL 17

Expert Comment

by:geobul
ID: 9825629
Forgot this:

type
 TDriveType = (dtUnknown, dtNoDrive, dtFloppy, dtFixed, dtNetwork, dtCDROM, dtRAM);
0
 
LVL 2

Expert Comment

by:TheLeader
ID: 9825696
0
 
LVL 17

Expert Comment

by:geobul
ID: 9881636
May I ask you why I received a 'B' grade? You got full working code of what you'd asked for in less than an hour. What else could I have done for you?
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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