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 Incorrect Function

error Incorrect Function

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

    Hi there, I'm trying to do overlapped IO on the serial port, but since I changed from non-overlapped the readfile and writefile calls fail with error incorrect function I changed the following

    m_ComPortHndl = CreateFile (sComPort,GENERIC_READ|GENERIC_WRITE,0,
    NULL,OPEN_EXISTING,
    FILE_FLAG_OVERLAPPED,NULL);

    i.e. added the file flag overlapped and also added overlapped structures to the read/write calls

    ReadFile( m_ComPortHndl, &nData, 1, &dwBytesRead, &ovRead)

    any ideas why I might be getting this?? Andy

    A 1 Reply Last reply
    0
    • A andyg 101

      Hi there, I'm trying to do overlapped IO on the serial port, but since I changed from non-overlapped the readfile and writefile calls fail with error incorrect function I changed the following

      m_ComPortHndl = CreateFile (sComPort,GENERIC_READ|GENERIC_WRITE,0,
      NULL,OPEN_EXISTING,
      FILE_FLAG_OVERLAPPED,NULL);

      i.e. added the file flag overlapped and also added overlapped structures to the read/write calls

      ReadFile( m_ComPortHndl, &nData, 1, &dwBytesRead, &ovRead)

      any ideas why I might be getting this?? Andy

      A Offline
      A Offline
      andyg 101
      wrote on last edited by
      #2

      Scratch that it was because I wasn't initialising the overlapped structures to zero OVERLAPPED ov = {0}; Andy

      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