GetFileSizeEx corrupts file handle
<p>Currently I'm using GetFileSizeEx to track how large a log files gets before I write to it. We have limited space and anything if we try to create a file larger than 100 megabytes we stop logging data. The problem is for some reason GetFileSizeEx will corrupt the file handle that I am using.</p>

<pre><code>if( hFileHandle != INVALID_HANDLE_VALUE &amp;&amp; hFileHandle != NULL )
{
 asDbgMsg = asDbgMsg + asDelimeter;
 dwBytesToWrite =asDbgMsg.Length();
 pWrtBuffer = asDbgMsg.c_str();
 // Get the file size we are about to write to.
 PLARGE_INTEGER lpFileSize;
 GetFileSizeEx(hFileHandle, lpFileSize);

 // Don't write out the file if it is more than 100 mb!
 if(lpFileSize-&gt;QuadPart &lt; 104857600)
 {
  WriteFile( hFileHandle, pWrtBuffer, dwBytesToWrite, &amp;dwBytesWritten, NULL );
 }
}
</code></pre>

<p>hFileHandle will go from a normal value (00000EB8) to ???? in Rad studio's debugger.</p>

<p>Now I've solved this by using the GetFileSize function instead:</p>

<pre><code>if( hFileHandle != INVALID_HANDLE_VALUE &amp;&amp; hFileHandle != NULL )
{
 asDbgMsg = asDbgMsg + asDelimeter;
 dwBytesToWrite =asDbgMsg.Length();
 pWrtBuffer = asDbgMsg.c_str();
 // Get the file size we are about to write too.
 DWORD test;
 GetFileSize(hFileHandle, &amp;test);
 // Don't write out the file if it is more than 100 mb!
 if(test &lt; 104857600)
 {
  WriteFile( hFileHandle, pWrtBuffer, dwBytesToWrite, &amp;dwBytesWritten, NULL );
 }
}
</code></pre>

<p>However, I'd rather not use the non-extended function. I've deleted the file to ensure no other process has a lock on it, but it still has an issue when its created the file. I should note that this error does not happen under builder 6, only Rad Studio 2010.</p>

<p>Thank you for the help.</p>
