How to give 'Everybody' full rights to a file (programmatically)
Posted
by egrunin
on Stack Overflow
See other posts from Stack Overflow
or by egrunin
Published on 2010-06-17T06:23:31Z
Indexed on
2010/06/17
6:43 UTC
Read the original article
Hit count: 236
I'm modifying an old C++ program to run on Vista. It does not require Admin privileges.
I've changed the code to put logfiles in \ProgramData\MyApp\. These logfiles are written with the stdio functions (fopen, fprintf, fclose).
Here's the problem:
UserA runs the program first, it creates
\ProgramData\MyApp\MyLogFile.txtUserB runs the program next, it tries to append to
MyLogFile.txtand gets access denied.
I tried creating a null SECURITY_DESCRIPTOR and passing that to CreateFile(). 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.
It's important that all users share the same logfiles, but it's also important that I change as little code as possible.
© Stack Overflow or respective owner