?
Solved

Size of a drive

Posted on 1998-07-20
5
Medium Priority
?
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Accepted Solution

by:
westy100697 earned 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

764 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