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

两盒软妹~` 提交于 2019-11-27 18:46:49

问题


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).


回答1:


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.




回答2:


See this example which finds the owner of a file using GetSecurityInfo and LookupAccountSid functions.



来源:https://stackoverflow.com/questions/11755422/c-how-to-retrieve-a-file-permission-and-ownership-via-win32-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!