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. Error no. 87 when trying to read from a drive...

Error no. 87 when trying to read from a drive...

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 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.
  • R Offline
    R Offline
    Redeemer dk
    wrote on last edited by
    #1

    I'm trying to open a drive, by specifying the lpFileName argument to be of the format "\\.\:" in CreateFile. But when i use ReadFile to read from the disk, i get an error, number 87 which means invalid parameter, anyone know what's wrong?

    char test\[32\];
    HANDLE hDrive = CreateFile("\\\\\\\\.\\\\H:", GENERIC\_READ, FILE\_SHARE\_WRITE /\* | FILE\_SHARE\_READ\*/ , NULL, OPEN\_EXISTING, FILE\_ATTRIBUTE\_NORMAL, NULL);
    DWORD dwBytesRead;
    
    ReadFile(hDrive, &test, 32, &dwBytesRead, NULL);
    
    CloseHandle(hDrive);
    

    Thanks all! -Rune SVendsen

    M 1 Reply Last reply
    0
    • R Redeemer dk

      I'm trying to open a drive, by specifying the lpFileName argument to be of the format "\\.\:" in CreateFile. But when i use ReadFile to read from the disk, i get an error, number 87 which means invalid parameter, anyone know what's wrong?

      char test\[32\];
      HANDLE hDrive = CreateFile("\\\\\\\\.\\\\H:", GENERIC\_READ, FILE\_SHARE\_WRITE /\* | FILE\_SHARE\_READ\*/ , NULL, OPEN\_EXISTING, FILE\_ATTRIBUTE\_NORMAL, NULL);
      DWORD dwBytesRead;
      
      ReadFile(hDrive, &test, 32, &dwBytesRead, NULL);
      
      CloseHandle(hDrive);
      

      Thanks all! -Rune SVendsen

      M Offline
      M Offline
      Mike Nordell
      wrote on last edited by
      #2

      Redeemer-dk wrote: anyone know what's wrong? Yes, and so does the MSDN documentation: Note that all I/O buffers must be sector aligned (aligned on addresses in memory that are integer multiples of the volume's sector size), even if the disk device is opened without the FILE_FLAG_NO_BUFFERING flag.

      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