Delphi - Using DeviceIoControl passing IOCTL_DISK_GET_LENGTH_INFO to get flash media physical size (Not Partition)

前端 未结 2 1841
-上瘾入骨i
-上瘾入骨i 2021-01-06 14:21

Alright this is the result of a couple of other questions. It appears I was doing something wrong with the suggestions and at this point have come up with an error when usi

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-06 14:53

    I see what might be happening here.

    Try this:

    For every "FILE_SHARE_READ", change it to "FILE_SHARE_WRITE Or FILE_SHARE_READ"

    From msdn:

    "If you want to open a volume using \.\X:, you must use FILE_SHARE_WRITE | FILE_SHARE_READ, not just FILE_SHARE_WRITE. If you omit FILE_SHARE_READ, you'll get ERROR_NOT_SUPPORTED on most volumes"

    http://msdn.microsoft.com/en-us/library/aa363858(v=vs.85).aspx

    EDIT:

    Your going to hate this, but the real reason it's failing is because your define for IOCTL_DISK_GET_LENGTH_INFO is wrong. Replace it with this:

    ((IOCTL_DISK_BASE shl 16) or (FILE_READ_ACCESS shl 14) or ($0017 shl 2) or METHOD_BUFFERED);
    

    Which turns out to be 0x7405C not 0x80070017

提交回复
热议问题