Solved

Get description of drives on the computer

Posted on 2003-11-26
5
204 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
Comment Utility
0
 
LVL 17

Accepted Solution

by:
geobul earned 125 total points
Comment Utility
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
Comment Utility
Forgot this:

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

Expert Comment

by:TheLeader
Comment Utility
0
 
LVL 17

Expert Comment

by:geobul
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

8 Experts available now in Live!

Get 1:1 Help Now