title: Windows Create File Access that only allows Owner to access the file (Win32)
body: <p>I'm trying to modify Windows access rights to a file in a way that only the owner (not even other Administrators) can access the file.  Somewhat the equivalent of unix chmod 700 file.</p>
  
  <p>I've played with denying rights to the general group (EVERYONE, ADMINISTRATORS) and granting them to the current user, but the current user always also loses the rights.  </p>
  
  <p>I tried to change the order (eas[0], eas[1]) and stuff, but without success.</p>
  
  <p>Ideas anyone?</p>
  
  <pre><code>    EXPLICIT_ACCESSA ea= { 0, }, eas[5]= { { 0, }, };
      PACL pacl= 0;
  
      ea.grfAccessPermissions = GENERIC_ALL;
      ea.grfAccessMode = DENY_ACCESS ;
      ea.grfInheritance = NO_INHERITANCE;
      ea.Trustee.TrusteeForm = TRUSTEE_IS_NAME;
      ea.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
      ea.Trustee.ptstrName = "EVERYONE";
      eas[0]= ea;
  
  
      ea.grfAccessPermissions = GENERIC_ALL;
      ea.grfAccessMode = GRANT_ACCESS ;
      ea.grfInheritance = NO_INHERITANCE;
      ea.Trustee.TrusteeForm = TRUSTEE_IS_NAME;
      ea.Trustee.TrusteeType = TRUSTEE_IS_USER;
      ea.Trustee.ptstrName = "CURRENT_USER";
      eas[1]= ea;
  
      rc= SetEntriesInAcl(2, &amp;eas[0], NULL, &amp;pacl);
  
      rc= SetNamedSecurityInfoA((LPSTR)filename, SE_FILE_OBJECT,
                                      DACL_SECURITY_INFORMATION,
                                      NULL, NULL, pacl, NULL);
  </code></pre>