Delphi - Tomar el espacio libre del HD

 
Vista:

Tomar el espacio libre del HD

Publicado por [DeK_OiN] (2 intervenciones) el 11/01/2001 00:00:00
Hola a todos.

Estoy haciendo un programita, y necesito que pueda ver el espacio libre del HD (la capacidad o el espacio utilizado, da lo mismo). Hay una api que se llama getfreediskspace pero yo no sé usarla.

a ver si alguien me ayuda

salu2 a to2
dek
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

tu respuesta

Publicado por Jose Luis Solano (10 intervenciones) el 09/02/2001 20:57:32
getfreediskspace no es muy confiable, ya que despues de los 2GB de espacio te
manda errores osea que te manda diferentes cantidades inclusive en numero
negativo, lo que sigue hace lo mismo y mas y creo que es man confiable.

en tu aplicacion añade un memo y un botón en el evento onclick del ultimo copia:

procedure TForm1.Button3Click(Sender: TObject); //<-----evento boton
procedure RunDosInMemo(Que:String;EnMemo:TMemo);
const
CUANTOBUFFER = 2000;
var
Seguridades : TSecurityAttributes;
PaLeer,PaEscribir : THandle;
start : TStartUpInfo;
ProcessInfo : TProcessInformation;
Buffer : Pchar;
BytesRead : DWord;
CuandoSale : DWord;
begin
with Seguridades do
begin
nlength := SizeOf(TSecurityAttributes);
binherithandle := true;
lpsecuritydescriptor := nil;
end;
{Creamos el pipe...}
if Createpipe (PaLeer, PaEscribir, @Seguridades, 0) then
begin
Buffer := AllocMem(CUANTOBUFFER + 1);
FillChar(Start,Sizeof(Start),#0);
start.cb := SizeOf(start);
start.hStdOutput := PaEscribir;
start.hStdInput := PaLeer;
start.dwFlags := STARTF_USESTDHANDLES +
STARTF_USESHOWWINDOW;
start.wShowWindow := SW_HIDE;

if CreateProcess(nil,
PChar(Que),
@Seguridades,
@Seguridades,
true,
NORMAL_PRIORITY_CLASS,
nil,
nil,
start,
ProcessInfo)
then
begin
{Espera a que termine la ejecucion}
repeat
CuandoSale := WaitForSingleObject( ProcessInfo.hProcess,100);
Application.ProcessMessages;
until (CuandoSale <> WAIT_TIMEOUT);
{Leemos la Pipe}
repeat
BytesRead := 0;
{Llenamos un troncho de la pipe, igual a nuestro buffer}
ReadFile(PaLeer,Buffer[0],CUANTOBUFFER,BytesRead,nil);
{La convertimos en una string terminada en cero}
Buffer[BytesRead]:= #0;
{Convertimos caracteres DOS a ANSI}
OemToAnsi(Buffer,Buffer);
EnMemo.Text := EnMemo.text + String(Buffer);
until (BytesRead < CUANTOBUFFER);
end;
FreeMem(Buffer);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
CloseHandle(PaLeer);
CloseHandle(PaEscribir);
end;
end;

begin
runDosInMemo('chkdsk.exe c:\',Memo1);
end;

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar