Solved

Size of a drive

Posted on 1998-07-20
5
271 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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…
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…
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 …

773 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