u盘容量获取.txt

来自「USB容量获取用DeviceIoControl得到U盘物理参数!」· 文本 代码 · 共 14 行

TXT
14
字号
U盘容量的获取

用DeviceIoControl得到U盘物理参数!
bResult = DeviceIoControl(hDevice,  // device to be queried
      IOCTL_DISK_GET_DRIVE_GEOMETRY,  // operation to perform
                             NULL, 0, // no input buffer
                            pdg, sizeof(*pdg),     // output buffer
                            &junk,                 // # bytes returned
                            (LPOVERLAPPED) NULL);  // synchronous I/O
总存储字节为

totalSize=pdg.Cylinders.QuadPart * (ULONG)pdg.TracksPerCylinder *(ULONG)pdg.SectorsPerTrack * (ULONG)pdg.BytesPerSector;
如果是电子元件做的U盘实际存储的字节数大于totalSize,用本本硬盘改的U盘就没问题,请教这是什么原因!

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?