Ver Mensaje Individual
  #9  
Antiguo 01-08-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 24
seoane Va por buen camino
Nunca había oído hablar de un MBR que no midiera 512 bytes, pero hay muchas cosas que desconozco. Aunque lo que si se es que el tamaño del sector depende de la geometría del disco y no del formateo que se haga del mismo, aunque también puedo estar equivocado

De todas formas si ese es todo el problema lo solucionamos fácilmente averiguando el tamaño del sector y actuando en consecuencia:

Código Delphi [-]
type
  DISK_GEOMETRY = record
    Cylinders: LARGE_INTEGER;
    MediaType: Integer;
    TracksPerCylinder: DWORD;
    SectorsPerTrack: DWORD;
    BytesPerSector: DWORD;
  end;

const
  IOCTL_DISK_GET_DRIVE_GEOMETRY = 458752;

function GetBytesPerSector(Drive: Integer): DWORD;
var
  hDisk: THandle;
  Geometry: DISK_GEOMETRY;
  Returned: DWORD;
begin
  Result:= 0;
  hDisk:= CreateFile(PChar('\\.\Physicaldrive' + IntToStr(Drive)),GENERIC_READ,
    FILE_SHARE_READ,nil,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0);
  if hDisk <> INVALID_HANDLE_VALUE then
  begin
    FillChar(Geometry,Sizeof(Geometry),0);
    if DeviceIoControl(hDisk,IOCTL_DISK_GET_DRIVE_GEOMETRY,nil,0,@Geometry,
      sizeof(Geometry),Returned,nil) then
     Result:= Geometry.BytesPerSector
    else ShowMessage(SysErrorMessage(GetLastError));
    CloseHandle(hDisk);
  end else ShowMessage(SysErrorMessage(GetLastError));
end;
Responder Con Cita