Go Back   FileForums > Game Backup > PC Games > PC Games - CD/DVD Conversions > Conversion Tutorials
Register FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 09-10-2016, 16:55
JRD!'s Avatar
JRD! JRD! is offline
Registered User
 
Join Date: Sep 2015
Location: Matrix
Posts: 274
Thanks: 225
Thanked 600 Times in 168 Posts
JRD! is on a distinguished road
Certainly the improved:
Code:
#ifdef UNICODE
  #define AW "W"
#else
  #define AW "A"
#endif

type
  TDiskInfo = record
    DriveRoot: string;
    FreeSpace: cardinal;
    TotalSpace: cardinal;
  end;

  TDiskInfos = array of TDiskInfo;

function GetDriveType(lpRootPathName: string): UINT;
  external 'GetDriveType{#AW}@kernel32.dll stdcall';
function GetLogicalDriveStrings(nBufferLength: DWORD; lpBuffer: string): DWORD;
  external 'GetLogicalDriveStrings{#AW}@kernel32.dll stdcall';

Function GetMaxFreeSpace(Value: String): String;
var
  S: String;
  I, J: Integer;
  DiskInfos: TDiskInfos;
begin
  I := 0; J:=0;
  if GetLogicalDriveStrings(0, #0) > 0 then
  begin
    SetLength(S, GetLogicalDriveStrings(0, #0));
    if GetLogicalDriveStrings(Length(S), S) > 0 then
    begin
      S := TrimRight(S) + #0;
      while Pos(#0, S) > 0 do
      begin
        if (GetDriveType(Copy(S, 1, Pos(#0, S) - 1)) = 3) then
        begin
          Inc(I);
          SetLength(DiskInfos, I);
          DiskInfos[I-1].DriveRoot:=Copy(S, 1, Pos(#0, S) - 1);
          GetSpaceOnDisk(DiskInfos[I-1].DriveRoot, True, DiskInfos[I-1].FreeSpace, DiskInfos[I-1].TotalSpace);
        end;
        Delete(S, 1, Pos(#0, S));
      end;
      for I := 0 to Length(DiskInfos) -1 do
      begin
        if I = 0 then
        J := DiskInfos[i].FreeSpace else
        begin
          if J > DiskInfos[i].FreeSpace then J := J else
          begin
            J := DiskInfos[i].FreeSpace;
            Result:=DiskInfos[i].DriveRoot;
          end;
        end;
      end;
    end;
  end;
end;
Attached Files
File Type: 7z GetMaxFreeSpace.7z (931 Bytes, 22 views)
__________________
Practice makes perfect.

Last edited by JRD!; 09-10-2016 at 16:57.
Reply With Quote
The Following 5 Users Say Thank You to JRD! For This Useful Post:
52098994 (09-10-2016), 78372 (02-07-2017), Chayan Manna (30-06-2017), pakrat2k2 (09-10-2016), SAM2712 (10-10-2016)
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Doom 3 (KillaWare version) DVD impossible to update and/or install Resurrection of Ev zlxvw PC Games 2 18-04-2005 09:56
DSM3 Install Questions deerayrose PS2 Games 5 11-04-2004 19:52
Alternative points for Origa chip install. Civic2000 PS2 Games 4 12-01-2002 01:19
Pool of Radiance Install Directory Problem.. HELP!! EEpyon2k PC Games 1 20-12-2001 10:00
Diablo II (backup) install problems... Maketty PC Games 2 03-08-2001 15:22



All times are GMT -7. The time now is 09:00.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com