找回密码
 加入
搜索
查看: 1548|回复: 2

[AU3基础] [已解决]请问读写扇区时用DllStructCreate和WinAPI_SetFilePointerEx只能是512倍数

[复制链接]
发表于 2012-3-8 09:43:21 | 显示全部楼层 |阅读模式
本帖最后由 iPAQ 于 2012-3-8 13:48 编辑

用Autoit读写扇区时发现以下两个函数:

$tBuffer = DllStructCreate("byte[512]")
_WinAPI_SetFilePointerEx($hHD,512,$FILE_BEGIN)

中的数据长度或偏移量位置都只能是512字节(一个扇区)的倍数,
然后执行_WinAPI_ReadFile读或_WinAPI_WriteFile写才成功,
设置成其他值,读取和写入都失败,$tBuffer指向的数据都还是0。

请问是否只能按照512字节为单位来读写?



; 分类里没有[已解决],不知咋办了,改标题了。

评分

参与人数 1金钱 +15 收起 理由
afan + 15 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2012-3-8 12:02:43 | 显示全部楼层
Alignment and File Access Requirements

As previously discussed, an application must meet certain requirements when working with files opened with FILE_FLAG_NO_BUFFERING. The following specifics apply:

    File access sizes, including the optional file offset in the OVERLAPPED structure, if specified, must be for a number of bytes that is an integer multiple of the volume sector size. For example, if the sector size is 512 bytes, an application can request reads and writes of 512, 1,024, 1,536, or 2,048 bytes, but not of 335, 981, or 7,171 bytes.
    File access buffer addresses for read and write operations should be physical sector-aligned, which means aligned on addresses in memory that are integer multiples of the volume's physical sector size. Depending on the disk, this requirement may not be enforced.
详细见MSDN的说明:http://msdn.microsoft.com/en-us/ ... 0%28v=vs.85%29.aspx

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2012-3-8 13:44:05 | 显示全部楼层
谢谢3mile答复!

看来只能按扇区为最小单位读写了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-30 19:34 , Processed in 0.077106 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表