Get permissions of a file or folder

1k Views Asked by At

Iam trying to get permissions on file/folder for current user. I found nice article about it here. I have tried to run this program but I got few erros and I dont know where I can find solutions to them. I tried to make my own version. Unfortunately when i try:

LPWSTR lpszPrimaryDC = NULL;
NetGetDCName(NULL, L"A", (LPBYTE *)&lpszPrimaryDC);

I got error: NERR_DCNotFound. How I can solve this problem?

2

There are 2 best solutions below

0
John Zwinck On

The documentation says that error is returned when it "Could not find the domain controller for the domain specified in the domainname parameter." Do you have a domain called "A"? If not, the function is right to fail (and you need to rethink why/how you are calling it).

0
mafonya On

The only way the code didn't crash and gave me correct answer to question: is file or folder readable?

`   
FILE *myFile = fopen(dirPath, "r");
if (myFile == 0) {
    // "File or Dir is not readable
}
`

Hope this helps. You can use the same for writing test with "w".