Solved

Size of a drive

Posted on 1998-07-20
5
269 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
GetDiskFreeSpace() was exactly what I was looking for... thanks
0
 

Expert Comment

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
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…

728 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

11 Experts available now in Live!

Get 1:1 Help Now