title: How do you write the end of a file opened with FILE_FLAG_NO_BUFFERING?
body: <p>I am using VB6 and the Win32 API to write data to a file, this functionality is for the export of data, therefore write performance to the disk is the key factor in my considerations. As such I am using the <code>FILE_FLAG_NO_BUFFERING</code> and <code>FILE_FLAG_WRITE_THROUGH</code> options when opening the file with a call to <code>CreateFile</code>.</p>
  
  <p><code>FILE_FLAG_NO_BUFFERING</code> requires that I use my own buffer and write data to the file in multiples of the disk's sector size, this is no problem generally, apart from the last part of data, which if it is not an exact multiple of the sector size will include character zero's padding out the file, how do I set the file size once the last block is written to not include these character zero's?</p>
  
  <p>I can use <code>SetEndOfFile</code> however this requires me to close the file and re-open it without using <code>FILE_FLAG_NO_BUFFERING</code>. I have seen someone talk about <code>NtSetInformationFile</code> however I cannot find how to use and declare this in VB6. <code>SetFileInformationByHandle</code> can do exactly what I want however it is only available in Windows Vista, my application needs to be compatible with previous versions of Windows.</p>