dwDesiredAccess in CreateFile API
-
Hi everybody, I don't know is this the right forum to ask this question. Guide me if I am wrong. Right now I am working on some network related file systems. My difficulty is to determine the desired access level of a file in its shared mode. For example, I have a file opened with some dwDesiredAccess level flags set using CreateFile API. Some other process is asking for the same file with a different dwDesiredAccess level flags which may or may not succeed when I call the CreateFile API. Is there a way I can determine the result of the second CreateFile API without calling it? ie, is there a way I can validate the second dwDesiredAccess by checking with the first dwDesiredAccess and return ERROR_SHARING_VIOLATION to the client without making a call to CreateFile API? Please let me know if some good articles or other useful information available anywhere. Thanks in advance
cheers Varghese Paul
-
Hi everybody, I don't know is this the right forum to ask this question. Guide me if I am wrong. Right now I am working on some network related file systems. My difficulty is to determine the desired access level of a file in its shared mode. For example, I have a file opened with some dwDesiredAccess level flags set using CreateFile API. Some other process is asking for the same file with a different dwDesiredAccess level flags which may or may not succeed when I call the CreateFile API. Is there a way I can determine the result of the second CreateFile API without calling it? ie, is there a way I can validate the second dwDesiredAccess by checking with the first dwDesiredAccess and return ERROR_SHARING_VIOLATION to the client without making a call to CreateFile API? Please let me know if some good articles or other useful information available anywhere. Thanks in advance
cheers Varghese Paul
Just check GetAclInformation([^] and ACL.
Величие не Бога может быть недооценена.
-
Hi everybody, I don't know is this the right forum to ask this question. Guide me if I am wrong. Right now I am working on some network related file systems. My difficulty is to determine the desired access level of a file in its shared mode. For example, I have a file opened with some dwDesiredAccess level flags set using CreateFile API. Some other process is asking for the same file with a different dwDesiredAccess level flags which may or may not succeed when I call the CreateFile API. Is there a way I can determine the result of the second CreateFile API without calling it? ie, is there a way I can validate the second dwDesiredAccess by checking with the first dwDesiredAccess and return ERROR_SHARING_VIOLATION to the client without making a call to CreateFile API? Please let me know if some good articles or other useful information available anywhere. Thanks in advance
cheers Varghese Paul
Hi Paul, In a nutshell, you just want to know the available access level of a file and you do not want to call
CreateFile
if the desired access level is not available for that file? If I have understood your query correctly, then you could try this://Use ncheck = 2 to check write permission, 4 for read only permission and 6 for read and write permission.
int nCheck = 0; //0 checks just for the existence of the file.
int nReturn = _taccess(_T("C:\\Users\\Rajesh\\Downloads\\7z465-x64.msi"), nCheck);if(nReturn == 0)
{
//Success - The file has the given mode.
}
if(nReturn == -1)
{
//The file does not have the given mode!
}It is a crappy thing, but it's life -^ Carlo Pallini
-
Hi everybody, I don't know is this the right forum to ask this question. Guide me if I am wrong. Right now I am working on some network related file systems. My difficulty is to determine the desired access level of a file in its shared mode. For example, I have a file opened with some dwDesiredAccess level flags set using CreateFile API. Some other process is asking for the same file with a different dwDesiredAccess level flags which may or may not succeed when I call the CreateFile API. Is there a way I can determine the result of the second CreateFile API without calling it? ie, is there a way I can validate the second dwDesiredAccess by checking with the first dwDesiredAccess and return ERROR_SHARING_VIOLATION to the client without making a call to CreateFile API? Please let me know if some good articles or other useful information available anywhere. Thanks in advance
cheers Varghese Paul
Varghese Paul M wrote:
Is there a way I can determine the result of the second CreateFile API without calling it? ie, is there a way I can validate the second dwDesiredAccess by checking with the first dwDesiredAccess and return ERROR_SHARING_VIOLATION to the client without making a call to CreateFile API?
I don't believe so...and anyway, even if you could, the results could be invalid (by someone opening another handle on the file) before you could use them. Just open the file and be done with it. If it fails, it fails! But Win32 will tell you, through a combination of return code and GetLastError.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p