1
我正在使用C#和pinvoke來讀取/寫入原始SD卡。我需要得到具有DeviceIoControl的總容量: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;
隨着1吉布的SD卡,該diskGeo.DiskSize是1011709440.爲什麼?
非常感謝,這是我正在尋找的答案。我需要使用pinvoke擦除分區中的信息。最後一點:使用hexplorer,我可以讀取/寫入1073741824字節,整個1 GiB。 – ric 2009-12-18 06:12:39