Solved

Get description of drives on the computer

Posted on 2003-11-26
5
214 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

790 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