title: How to give 'Everybody' full rights to a file (programmatically)
body: <p>I'm modifying an old C++ program to run on Vista. It does not require Admin privileges. </p>
  
  <p>I've changed the code to put logfiles in <code>\ProgramData\MyApp\</code>. These logfiles are written with the <code>stdio</code> functions (<code>fopen</code>, <code>fprintf</code>, <code>fclose</code>).</p>
  
  <p>Here's the problem:</p>
  
  <ol>
  <li><p>UserA runs the program first, it creates <code>\ProgramData\MyApp\MyLogFile.txt</code> using <code>CreateFile()</code></p></li>
  <li><p>UserB runs the program next, it tries to append to <code>MyLogFile.txt</code> and gets access denied.</p></li>
  </ol>
  
  <p>I tried creating a null <code>SECURITY_DESCRIPTOR</code> and passing that to <code>CreateFile()</code>. That does create a file with "no permissions assigned", but it seems as if the first user to write to the file takes ownership and afterwards all the other non-admin users are out of luck.</p>
  
  <p>It's important that all users share the same logfiles, but it's also important that I change as little code as possible.</p>
  
  <p><strong>Edited to add:</strong></p>
  
  <p><code>\ProgramData\MyApp</code> is created by a standard Visual Studio installer. (I don't see any place to set directory security.) When it creates <code>\MyApp</code> it grants <code>Users</code> these permissions:</p>
  
  <pre><code>Read &amp; execute  
  List folder contents
  Read
  Special permissions
  </code></pre>
  
  <p>Under <code>Advanced</code> I see that Special permissions includes:</p>
  
  <pre><code>Create files / write data
  Create folders / append data
  Write attributes
  Write extended attributes
  </code></pre>