Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. dwDesiredAccess in CreateFile API

dwDesiredAccess in CreateFile API

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionsysadminjsonhelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Varghese Paul M
    wrote on last edited by
    #1

    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

    A R S 3 Replies Last reply
    0
    • V Varghese Paul M

      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

      A Offline
      A Offline
      Adam Roderick J
      wrote on last edited by
      #2

      Just check GetAclInformation([^] and ACL.

      Величие не Бога может быть недооценена.

      1 Reply Last reply
      0
      • V Varghese Paul M

        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

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • V Varghese Paul M

          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

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups