ItsMe
asked on
Get Capacity of whole HDD
hi ! how can i get the capacity of my whole fixed drives ?
kind regards
ItsMe
(must be work under nt/95/98/2000)
kind regards
ItsMe
(must be work under nt/95/98/2000)
or a more complete solution:
procedure TForm1.Button1Click(Sender : TObject);
var
Directory: PChar;
FreeAvailable, TotalSpace: Int64;
TotalFree: PLargeInteger;
msg: string;
begin
Directory:='C:';
if GetDiskFreeSpaceEx(Directo ry,FreeAva ilable,Tot alSpace,To talFree) then
begin
msg:= 'Drive ' + Directory;
msg:= msg + 'Total Capacity: ' + inttostr(TotalSpace) + ' bytes'#13#10;
msg:= msg + 'Used Capacity: ' + inttostr(TotalSpace - FreeAvailable) + ' bytes'#13#10;
msg:= msg + 'Free Capacity: ' + inttostr(FreeAvailable) + ' bytes'#13#10;
ShowMessage(msg);
end;
end;
procedure TForm1.Button1Click(Sender
var
Directory: PChar;
FreeAvailable, TotalSpace: Int64;
TotalFree: PLargeInteger;
msg: string;
begin
Directory:='C:';
if GetDiskFreeSpaceEx(Directo
begin
msg:= 'Drive ' + Directory;
msg:= msg + 'Total Capacity: ' + inttostr(TotalSpace) + ' bytes'#13#10;
msg:= msg + 'Used Capacity: ' + inttostr(TotalSpace - FreeAvailable) + ' bytes'#13#10;
msg:= msg + 'Free Capacity: ' + inttostr(FreeAvailable) + ' bytes'#13#10;
ShowMessage(msg);
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mnasman's answer works under win2k pro, and win98 SE
the only tricky part is to make dure the drive # is correct
the only tricky part is to make dure the drive # is correct
ASKER
works fine,
thanks everybody ;-)
ItsMe
thanks everybody ;-)
ItsMe
you could try something like:
procedure TForm1.Button1Click(Sender
var
FreeAvailable, TotalSpace: Int64;
TotalFree: PLargeInteger;
begin
if GetDiskFreeSpaceEx('C:',Fr
label1.caption:= inttostr(TotalSpace);
end;
There is GetDiskFreeSpace function aswell, but it does not report on drives larger than 2GB. From the online help:
[New - Windows NT]
[New - Windows 95, OEM Service Release 2]
The GetDiskFreeSpaceEx function obtains information about the amount of space available on a disk volume: the total amount of space, the total amount of free space, and the total amount of free space available to the user associated with the calling thread.
Windows 95 OSR 2:
The GetDiskFreeSpaceEx function is available on Windows 95 systems beginning with OEM Service Release 2 (OSR 2).
Use the GetVersionEx function to determine that a system is running OSR 2 or a later release of the Windows 95 operating system. The GetVersionEx function fills in the members of an OSVERSIONINFO data structure. If the dwPlatformId member of that structure is VER_PLATFORM_WIN32_WINDOWS
Once you have determined that a system is running OSR 2, call the LoadLibrary or LoadLibraryEx function to load the KERNEL32.DLL file, then call the GetProcAddress function to obtain an address for the GetDiskFreeSpaceEx function. Use that address to call the function.
regards
Aubs