Solved

Delphi Programming question

Posted on 1997-09-24
6
917 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
[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
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
Industry Leaders: 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!

 
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

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month3 days, 17 hours left to enroll

630 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