function StrToPChar( Str: String ): PChar;
begin
Result := StrAlloc(Length(Str)+1);
{$IFDEF WIN32}
StrCopy( Result, PChar(Str));
{$ELSE}
StrPCopy( Result, Str );
{$ENDIF}
end;
Function GetByteNumer(str:pchar):integer;
begin
if LOWERCASE(strpas(str))='c:\' then
result:=3
else if LOWERCASE(strpas(str))='d:\' then
result:=4
else if LOWERCASE(strpas(str))='e:\' then
result:=5
else if LOWERCASE(strpas(str))='f:\' then
result:=6
else if LOWERCASE(strpas(str))='g:\' then
result:=7
else if LOWERCASE(strpas(str))='h:\' then
result:=8
else
result:=9;
end;
procedure GetSapce;
var
drivername:PChar;
path:String;
TotalSpace,FreeSpace:int64;
begin
path:='c:\';
drivername:=StrToPChar(path);
//或者drivername:=PChar(path);
num:=GetByteNumer(drivername);
TotalSpace:=disksize(num); //总容量
FreeSpace:=diskfree(num); //剩余空间
end;