Solved

Delphi Programming question

Posted on 1997-09-24
6
910 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

14 Experts available now in Live!

Get 1:1 Help Now