title: How to create temporary file (0x100) to accelerate application
body: <p>I have seen that Windows system use temporary files to increase the performance of some tasks. Those files are marked with the 0x100 attribute when i look at them. I have got the following text from Microsoft: "</p>
  
  <blockquote>
    <p>By using CreateFile() with the
    FILE_ATTRIBUTE_TEMPORARY flag, you let
    the system know that the file is
    likely to be short lived. The
    temporary file is created as a normal
    file. The system needs to do a minimal
    amount of lazy writes to the file
    system to keep the disk structures
    (directories and so forth) consistent.
    This gives the appearance that the
    file has been written to the disk
    ."</p>
  </blockquote>
  
  <p>Any example of creating such temporary file using Delphi? </p>
  
  <p>Thanks. </p>
  
  <p>[EDIT] </p>
  
  <p>Complementary question: what could be the context of using such file, example, could it be used for a log system. the log being this file with the temp attribute? Would it be faster and less memory prone when log get very large? </p>
  
  <p>[EDIT]</p>
  
  <p>Ok i have create file using solution given by schnaader below with the FILE_ATTRIBUTE_TEMPORARY:</p>
  
  <pre><code>hMyFile := CreateFile(FileName,
                        GENERIC_WRITE,
                        0,
                        nil,
                        CREATE_ALWAYS,
                        FILE_ATTRIBUTE_TEMPORARY,
                        0); 
  </code></pre>
  
  <p>Such file get the 0x120 attribute when created. Thus a temporary file according to system.  </p>
  
  <p>I  have also create a file with the FILE_FLAG_DELETE_ON_CLOSE flag (<a href="http://blogs.msdn.com/larryosterman/archive/2004/04/19/116084.aspx" rel="nofollow noreferrer">see this article by L. Osterman</a>). </p>
  
  <p>So:</p>
  
  <pre><code>hMyFile := CreateFile(FileName,
                        GENERIC_WRITE,
                        0,
                        nil,
                        CREATE_ALWAYS,
                        FILE_FLAG_DELETE_ON_CLOSE,
                        0);
  </code></pre>
  
  <p>This file gets no attribute and the file is automatically deleted when the application is closed or destroyed. </p>
  
  <p><strong>I did not find how to combine the attribute and the flag</strong>. Any idea? </p>
  
  <p>Thanks</p>