Home > Software engineering >  How to use VB FILE_FLAG_NO_BUFFERING written to disk, with VB code
How to use VB FILE_FLAG_NO_BUFFERING written to disk, with VB code

Time:09-27

How to use VB FILE_FLAG_NO_BUFFERING written to disk, with VB code

CodePudding user response:

FILE_FLAG_NO_BUFFERING
Instructs the system to open the file with no intermediate the buffering or caching. When combined with FILE_FLAG_OVERLAPPED, the flag gives maximum asynchronous performance, because the I/O does not rely on the synchronous operations of the memory manager. Or, some I/O operations will take longer, because the data is not being by in the cache.
An application must meet certain requirements when working with files the opened with FILE_FLAG_NO_BUFFERING:

The File access must begin at byte offsets the within the File that are integer multiples of the volume 's sector size.
The File access must be for Numbers of bytes that are integer multiples of the volume 's sector size. For example, if the sector size is 512 bytes, an application can request reads and writes of 512, 1024, or 2048 bytes, but not of 335, 981, or 7171 bytes.
Buffer addresses for the read and write operations must be on sector aligned (aligned addresses in memory that are integer multiples of the volume 's sector size).
One way to align buffers on integer multiples of the volume sector size is to use VirtualAlloc to the allocate the buffers. It allocates memory on that is aligned addresses that are integer multiples of the operating system 's memory page size. Because both the memory page and volume sector sizes are powers of 2, this is also aligned on memory addresses that are integer multiples of a volume' s sector size.

An application can determine a volume 's sector size by calling the GetDiskFreeSpace function.

CodePudding user response:

It is better for example code
  •  Tags:  
  • API
  • Related