Solved

Size of a drive

Posted on 1998-07-20
5
274 Views
Last Modified: 2010-08-05
Is there an easy way to obtain the size of a drive?
(ie is there some function call that will return a drive's size/capacity)

Also is there a function to obtain the free space available on a disk drive??
0
Comment
Question by:rafy
5 Comments
 

Accepted Solution

by:
westy100697 earned 50 total points
ID: 1358277
Have you had a look at the Win32 help file. It has a function for GetDiskFreeSpace() and also has help topic for GetDrive type also. See if that helps. I hope you are talking about D3??

WESTY
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1358278
Use DiskSize and DiskFree:

  Showmessage(IntToStr(DiskSize(0) div 1024) + ' Kbytes capacity.');
  Showmessage(IntToStr(DiskFree(0) div 1024) + ' Kbytes free.');

0
 
LVL 4

Expert Comment

by:erajoj
ID: 1358279
DO NOT USE DISKSIZE AND DISKFREE!
They only support partitions with less than 2GB.

Comp is a 64-bit integer type and will support disks
up to 9,223,372,036,854,775,807 Byte.

Here's a simple solution:

  cmpDF, cmpDS, cmpDU: Comp;
  dwSPC, dwBPS, dwNFC, dwTNC: DWORD;

  GetDiskFreeSpace( PChar( chDriveLetter + ':\' ), dwSPC, dwBPS, dwNFC, dwTNC );
  cmpDS := Comp( dwSPC ) * dwBPS * dwTNC; // disk size
  cmpDF := Comp( dwSPC ) * dwBPS * dwNFC; // disk free
  cmpDU := cmpDS - cmpDF;  // disk used, huh?

/// John
0
 

Author Comment

by:rafy
ID: 1358280
GetDiskFreeSpace() was exactly what I was looking for... thanks
0
 

Expert Comment

by:kake26
ID: 9167181
I use Delphi 6 personal and I've tried it both ways, the API and DISKSIZE and DISKFREE. I have two 10 GB partitions and it seems to have no problem with it.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Downloading email attachments 2 79
Create a path if not exists 7 87
how to update exe applicatio from internet ? 6 86
How to Get Images From Server using App Tethering 11 39
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
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 …

808 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