简体   繁体   English

C ++如何通过Win32 API检索文件权限和所有权

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

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. 我一直在互联网上搜索如何使用win32 api检索文件的权限和所有权,但我没有任何答案。

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. 我是win32 api的新手,从Internet上阅读了一些指南,试图分析与该api相关的一些代码,但我仍然一无所知。

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). 很抱歉,我无法通过添加一些代码来做到更具体,我看不出有任何理由导入自己的任何代码,因为剩下的唯一功能是检索此信息的功能,其余功能很简单(用户界面等)。

See Retrieving NTFS Permissions with C++ . 请参阅使用C ++检索NTFS权限 But, basically, you call GetFileSecurity to get a security descriptor for the file. 但是,基本上,您可以调用GetFileSecurity来获取文件的安全描述符。 From that, you can get the access control list (ACL) and the owner and permissions. 由此,您可以获得访问控制列表(ACL)以及所有者和权限。

请参GetSecurityInfo 示例该示例使用GetSecurityInfoLookupAccountSid函数查找文件的所有者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM