title: Cannot eject USB drive on XP even after TFileStream is freed
body: <p>I am using Delphi XE3. Below is my code:</p>
  <pre class="lang-pascal prettyprint-override"><code>procedure TForm1.Button1Click(Sender: TObject);
  var
    Data: Byte;
    FileStream: TFileStream;
  begin
    if SaveDialog1.Execute then
    begin
      FileStream := TFileStream.Create(SaveDialog1.FileName, fmCreate or fmOpenWrite or fmShareExclusive);
      try
        FileStream.Write(Data, SizeOf(Data));
      finally
        FreeAndNil(FileStream);
      end;
    end;
  end;
  </code></pre>
  <p>When using this code to write data to a file on a USB drive, I find that even though the file stream is freed, I still cannot eject the USB drive under Windows XP. The system says the USB drive is still in use. I need to close the whole program to eject the USB drive.</p>
  <p>However, under Windows 7, there is no such a problem.</p>
  <p>Why?</p>