I work in Linux. In Linux with stat function, we can extract the permissions of a file.

Similarly how can we extract the permissions of a file in windows. 

\_stat function in msdn states that permission bits are set in the stat buffer. But it does not give how to extract them. 

<http://msdn.microsoft.com/en-us/library/14h5k7ff%28VS.71%29.aspx>
['https://Stackoverflow.com/questions/3449465', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/266836/']
Windows uses an ACL (Access Control List) to control access to a file (or other kernel object). You can get the ACL for a file with [`GetFileSecurity`](http://msdn.microsoft.com/en-us/library/aa446639(VS.85).aspx) (you want the DACL, not the SACL). You can then get the actual permissions (rights) from that with [`GetEffectiveRightsFromAcl`](http://msdn.microsoft.com/en-us/library/aa446637(VS.85).aspx).

This has a race condition, so it's rarely a good idea though. In particular, between the time you retrieve the DACL and the time you try to do something with the file, the DACL may have changed, so what you retrieved is no longer correct.
MSDN doesn't have nearly as many hyperlinks as it should, you need to search a little to find [`_stat` Structure `st_mode` Field Constants](http://msdn.microsoft.com/en-us/library/3kyc8381.aspx).

On both Unix and Windows, you only get the basic permissions of a file, not its access control lists. Since Windows uses ACLs a lot, `_stat` won't give you much useful information. You need to use native Windows API functions to get the ACL.