gpt4 book ai didi

c++ - 调用 MapViewOfFile 时出错

转载 作者:行者123 更新时间:2023-11-28 00:40:01 25 4
gpt4 key购买 nike

我正在尝试使用需要 DWORD 的函数。

这些是规范:

dwFileOffsetHigh [in]

A high-order DWORD of the file offset where the view begins. dwFileOffsetLow [in]

A low-order DWORD of the file offset where the view is to begin. The combination of the high and low offsets must specify an offset within the file mapping. They must also match the memory allocation granularity of the system. That is, the offset must be a multiple of the allocation granularity. To obtain the memory allocation granularity of the system, use the GetSystemInfo function, which fills in the members of a SYSTEM_INFO structure.

函数因错误参数不正确而失败。

unsigned long lByteStart=200959959;
unsigned long lByteLen=66964224;

MapViewOfFile( *phMapping, FILE_MAP_READ, 0, lByteStart, lByteLen );

我不关心高或低或低,因为我不理解它,只是希望它能起作用。

既然它不起作用,有人能告诉我我做错了什么以及我需要做什么才能正确地做吗?

最佳答案

问题不在于高/低部分,您做对了。问题是“偏移量必须是分配粒度的倍数”。我不认为你的是。

分配粒度的典型值是 4096,但您应该检查它在您的系统上是什么,正如引述所说。

关于c++ - 调用 MapViewOfFile 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19339111/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com