Registriert seit: 23. Mai 2005
312 Beiträge
|
Re: Beliebig große leere Dateien erzeugen
16. Jan 2006, 17:23
Hi,
du könntest es so machen:
Delphi-Quellcode:
function GetDiskSize(drive: Char; var free_size, total_size: Int64): Boolean;
var
RootPath: array[0..4] of Char;
RootPtr: PChar;
current_dir: string;
begin
RootPath[0] := Drive;
RootPath[1] := ':';
RootPath[2] := '\';
RootPath[3] := #0;
RootPtr := RootPath;
current_dir := GetCurrentDir;
if SetCurrentDir(drive + ':\') then
begin
GetDiskFreeSpaceEx(RootPtr, Free_size, Total_size, nil);
SetCurrentDir(current_dir);
Result := True;
end
else
begin
Result := False;
Free_size := -1;
Total_size := -1;
end;
end;
procedure SpammHDD(Path: string);
var
fs: TFileStream;
free_size, total_size: Int64;
begin
if GetDiskSize(Path[1], free_size, total_size) then
fs := TFileStream.Create(Path, fmCreate);
try
fs.Size := free_size - 100000;
finally
fs.Free;
end;
end;
greetz
Edit: Besser Version.
|
|
Zitat
|