Solved

Size of a drive

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi : could not find program, '...exe' 2 212
Delphi selector screen 2 91
How to load 2 images in same column in Delphi 2 67
Delphi, TImage, Png 2 19
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…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 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