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. WriteFile return access denied?

WriteFile return access denied?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
8 Posts 3 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.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    WriteFile return access denied? while i providing admin privileges please help me for this.

    HANDLE hCD = CreateFile (file_Name, GENERIC_READ|GENERIC_WRITE,
    FILE_SHARE_READ|FILE_SHARE_WRITE,
    NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
    NULL);

    WriteFile (hCD, Buffer, Size, &bytesWritten, NULL);

    its fails with access denied.

    thanks in advance.

    L J 2 Replies Last reply
    0
    • L Le rner

      WriteFile return access denied? while i providing admin privileges please help me for this.

      HANDLE hCD = CreateFile (file_Name, GENERIC_READ|GENERIC_WRITE,
      FILE_SHARE_READ|FILE_SHARE_WRITE,
      NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
      NULL);

      WriteFile (hCD, Buffer, Size, &bytesWritten, NULL);

      its fails with access denied.

      thanks in advance.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Check the file name and make sure that it is where you think it is, and is not protected against write access.

      L 1 Reply Last reply
      0
      • L Lost User

        Check the file name and make sure that it is where you think it is, and is not protected against write access.

        L Offline
        L Offline
        Le rner
        wrote on last edited by
        #3

        i chk all is ok n its not write protected at all.... now what can i do

        L 2 Replies Last reply
        0
        • L Le rner

          i chk all is ok n its not write protected at all.... now what can i do

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Sorry, it is impossible to tell what may be the problem without access to your system.

          1 Reply Last reply
          0
          • L Le rner

            i chk all is ok n its not write protected at all.... now what can i do

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            I just tried your actual code on my system and it works fine, so the problem must definitely be something to do with the file or its location.

            L 1 Reply Last reply
            0
            • L Lost User

              I just tried your actual code on my system and it works fine, so the problem must definitely be something to do with the file or its location.

              L Offline
              L Offline
              Le rner
              wrote on last edited by
              #6

              its my card storage connected on usb 3.0 port on usb 2.0 its working fine

              L 1 Reply Last reply
              0
              • L Le rner

                its my card storage connected on usb 3.0 port on usb 2.0 its working fine

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                You need to check in Settings to make sure it is accessible. You can try a simple copy from File Explorer as a start.

                1 Reply Last reply
                0
                • L Le rner

                  WriteFile return access denied? while i providing admin privileges please help me for this.

                  HANDLE hCD = CreateFile (file_Name, GENERIC_READ|GENERIC_WRITE,
                  FILE_SHARE_READ|FILE_SHARE_WRITE,
                  NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
                  NULL);

                  WriteFile (hCD, Buffer, Size, &bytesWritten, NULL);

                  its fails with access denied.

                  thanks in advance.

                  J Offline
                  J Offline
                  jschell
                  wrote on last edited by
                  #8

                  Two things First you are a person which has specific access to the file system. Your application is not you. The access it has depends on how it runs. You as a person are likely checking the access but that does not mean the application has it. Second the directories also determine access. You can programmatically request information about permissions. Write some code that returns that information from EACH level of the directory tree including the drive letter. Then inspect that.

                  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