Ver Mensaje Individual
  #1  
Antiguo 16-10-2008
Avatar de kurono
[kurono] kurono is offline
Miembro Premium
 
Registrado: jul 2007
Ubicación: Republica Dominicana
Posts: 1.126
Reputación: 18
kurono Va por buen camino
como modificar este codigo

hola amigos del foro me gustaria modificar este codigo q le muestro pues se trata de un codigo que hiso nuestro amigo hackall en donde el muestra como identificar sectores dañado de un disco pues bien el codigo funciona de maravilla pero el incombeniente es que la unidad a comprobar estaria por defecto al ejecutarse y me gustaria poder elegir una unidad para comprobar pues ni mas ni menos le muestro el codigo


Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
 
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('\\.\g:', 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
     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;
end.

Última edición por kurono fecha: 16-10-2008 a las 01:44:40.
Responder Con Cita