Ver Mensaje Individual
  #7  
Antiguo 18-10-2008
cmm07 cmm07 is offline
Miembro
 
Registrado: nov 2007
Posts: 526
Reputación: 17
cmm07 Va por buen camino
si quieres cambiarlo en tiempo de ejecucion podria ser así una funcion:

Código Delphi [-]
function verifica(Unidad: Char): PAnsiChar;
var
 hDevice, Dummy, Sectors, Sector: Cardinal;
 Buffer: array [0..$FFFF] of Byte;
 Geometry: record
  Cylinders: Int64;
  MediaType,
  TracksPerCylinder,
  SectorsPerTrack,
  BytesPerSector: Cardinal;
 end;

begin
 SetErrorMode(SEM_FAILCRITICALERRORS);
 hDevice := CreateFile(PChar('\\.\'+Unidad+':'), GENERIC_READ, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);
 if hDevice <> INVALID_HANDLE_VALUE then
  begin
   DeviceIoControl(hDevice, $70000{IOCTL_DISK_GET_DRIVE_GEOMETRY}, nil, 0, @Geometry, SizeOf(Geometry), Dummy, nil);
   Sectors := Geometry.SectorsPerTrack * Geometry.TracksPerCylinder * Geometry.Cylinders;
   for Sector := 0 to Sectors - 1 do
    begin
     Form1.Label1.Caption := 'Leyendo el sector #' + IntToStr(Sector) + '...';
     Application.ProcessMessages; // Use a thread !!!
     if not ReadFile(hDevice, Buffer, Geometry.BytesPerSector, Dummy, nil) then
      ShowMessage('El sector #' + IntToStr(Sector) + ' esta dañado !');
    end;
   CloseHandle(hDevice);
  end;
end;

Para usarlo:

Código Delphi [-]
Verifica('C');

bueno espero poder ayudar, este codigo esta creado sin comprobarse...



54LU2

Última edición por cmm07 fecha: 18-10-2008 a las 01:10:50.
Responder Con Cita