Solved

Delphi Programming question

Posted on 1997-09-24
6
914 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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