Solved

Delphi Programming question

Posted on 1997-09-24
6
913 Views
Last Modified: 2008-03-06
could someone give me an exemple of using
getdiskfreespaceex with delphi, I mean with the types declaration and the call .. I tried but I can't get it to run without bugs. I'm using delphi 3 c/S and osr2
it's a function of osr2, it is documented in the c++builder
ms-sdk help, but if u check the delphi units you will see
that it's there ;)
0
Comment
Question by:jeurk
6 Comments
 
LVL 3

Expert Comment

by:mirek071497
ID: 1346125
Hi
This is not answer. I try find getDiskFreeSpaceEx in MS-SDK and in Delphi, but i can't find ? If this exist ? I can find only getDiskFreeSpace.
0
 
LVL 4

Author Comment

by:jeurk
ID: 1346126
Edited text of question
0
 
LVL 4

Author Comment

by:jeurk
ID: 1346127
Adjusted points to 80
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:ronit051397
ID: 1346128
What exactly do you need?
Information about the clusters or information about disk space?
0
 
LVL 4

Author Comment

by:jeurk
ID: 1346129
Some precisions:
I want to get the free disk space available, It already
works with getdiskfreespace, but I want to use getdiskfreespaceEx
Please just show me the right manner to call that functions
with the right parameters, U know, I try to use it but It
seems to me that it does not work as it should, I think
that maybe my parameter do not have the right type, because
the ms-sdk shows c-typed functions and I'm not sure
of my translation.
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 40 total points
ID: 1346130
When I tried GetDiskFreeSpaceEx I got Access Violations.  It turns out that it is desclared incorrectly in Windows.pas.  It does NOT use Integers for the parameters (32 bits), but instead uses 64-bit structures called ULARGE_INTEGER (in C) or TLargeInteger (in Delphi).

Redeclare it as follows in your interface section:
function GetDiskFreeSpaceEx(lpDirectoryName: PChar;
  var lpFreeBytesAvailableToCaller, lpTotalNumberOfBytes: TLargeInteger;
  lpTotalNumberOfFreeBytes: PLargeInteger): BOOL; stdcall;

In your implementation section, put the following:
function GetDiskFreeSpaceEx; external kernel32 name 'GetDiskFreeSpaceExA';

To call it, do the following:
procedure TForm1.GetBytes;
var
  FreeBytes, TotBytes, TotFreeBytes: TLargeInteger;
begin
  GetDiskFreeSpaceEx('C:\', FreeBytes, TotBytes, @TotFreeBytes);
  ShowMessage('Free Bytes (Available to caller) = ' + FloatToStr(FreeBytes.QuadPart));
  ShowMessage('Total Bytes = ' + FloatToStr(TotBytes.QuadPart));
  ShowMessage('Total Free Bytes = ' + FloatToStr(TotFreeBytes.QuadPart));
end;

Hope this works for you.
JB

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

30 Experts available now in Live!

Get 1:1 Help Now