Fórum Verificar o espaco que tem em dico... #175370
16/08/2003
0
Como faco para verificar o espaco que tem em disco e o tamanho do HD...
Desde ja muito GRATO!
Desde ja muito GRATO!
Programadorjlle
Curtir tópico
+ 0
Responder
Posts
16/08/2003
Cebikyn
Use a função abaixo:
Para usar a função:
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); // this to turn back to original dir SetCurrentDir(current_dir); Result := True; end else begin Result := False; Free_size := -1; Total_size := -1; end; end;
Para usar a função:
var espaco_livre, espaco_total: Int64; begin if GetDiskSize(´C´, espaco_livre, espaco_total) then ShowMessage(´Espaço livre = ´ + IntToStr(espaco_livre) + #13 + ´Espaço total = ´ + IntToStr(espaco_total)) else ShowMessage(´Drive não acessível´); end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)