Я использую C # и pinvoke для чтения / записи сырой SD-карты. Мне нужно получить общую емкость с deviceiocontrol:
[StructLayout(LayoutKind.Sequential)]
public struct DISK_GEOMETRY
{
public long Cylinders;
public int MediaType;
public int TracksPerCylinder;
public int SectorsPerTrack;
public int BytesPerSector;
public long DiskSize
{
get
{
return Cylinders * (long)TracksPerCylinder * (long)SectorsPerTrack * (long)BytesPerSector;
}
}
}
...
uint dummy;
DISK_GEOMETRY diskGeo = new DISK_GEOMETRY();
DeviceIoControl(safeHandle, EIOControlCode.DiskGetDriveGeometry, IntPtr.Zero, 0,
ref diskGeo, (uint)Marshal.SizeOf(typeof(DISK_GEOMETRY)), out dummy, IntPtr.Zero);
this.sectorSize = diskGeo.BytesPerSector;
this.bufferSize = this.sectorSize * 16384;
this.diskSize = diskGeo.DiskSize;
При SD-карте 1 ГБ диск Geo.DiskSize равен 1011709440. Почему?