Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

_access() problems with XP

Status
Not open for further replies.

nivone

Programmer
Jul 2, 2002
33
IL
HI,

I have created a file and removed all users and groups from the Security tab (file properties).
In the Advanced window in the Security tab, I also removed the check box for "Inherit from parent the permission..."

When I try to open the file from the Explorer I get a "Access is denied" error message.

But when I try to check this file for READ permissions using the _access() function I get return code "0" which means that the file has reading permission.
I get the same result if I check WRITE permission.
I got the function to work as expected only when I checked existence of file.

The line of code is: _access("c:\filename", 4).
- Do you know of problems with XP when using _access()?
- Maybe the function is OK but I didn't remove the READ permission correctly?
 
Did you make the file ReadOnly (i.e. not using the Security tab)?

Does this problem happen on any other version of Windows?

My guess is that access() has no knowledge of NTFS permissions and is only checking the basic FAT file properties.
 
HI,

Once I removed the groups and users from the security tab, the Read Only checkbox was cleared.
I don't have any other Windows versions at the moment.
Assuming it's a FAT/NTFS issue, Is there a generic way in Windows to check for READ/WRITE permissions? One that will work on Windows 2000 and above, FAT and NTFS?

Thanks.
 
Maybe GetFileAttributesEx()? You can find info about it on the MSDN site.
 
GetFileAttributes yields FAT-style attributes only (and ...Ex does the same). VS RTL _access() is a simple call to the GetFileAttributes (check read-only attribute).
Try GetFileSecurity instead of GetFileAttributes/_access.
Sorry, I have no ready-to-use snippet now...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top