C++ How to retrieve a file permission and ownership via win32 api

avi sabag picture avi sabag · Aug 1, 2012 · Viewed 10.8k times · Source

I've been searching over the internet how to retrieve permissions and ownership of a file using win32 api, and yet I have no answer.

I'm new with the win32 api , read some guides from the internet, tried to analyze some code associating with this api and still I'm clueless.

Could you guys help me out with some piece of advice or some directions , tips etc.

I'm sorry that I can't be more specific than that by adding some code, I don't see any reason to import any code of my own since the only remaining function is the one retrieving this information and the rest is simple(User interface and etc).

Answer

Roger Lipscombe picture Roger Lipscombe · Aug 1, 2012

See Retrieving NTFS Permissions with C++. But, basically, you call GetFileSecurity to get a security descriptor for the file. From that, you can get the access control list (ACL) and the owner and permissions.