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, 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; 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:
bueno espero poder ayudar, este codigo esta creado sin comprobarse...
54LU2