Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6118735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:28:16+00:00 2026-05-23T15:28:16+00:00

I want to read some data from a device connected to a COM port.

  • 0

I want to read some data from a device connected to a COM port.

  • HANDLE handle =CreateFileW(L"\\\\.\\COM3", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);

    gives me a valid HANDLE which is then configured via GetCommState and SetCommState.

  • OVERLAPPED ol = {0};

    char buffer[1024];

    ol.Offset = 0;

    ol.OffsetHigh = 0;

    ReadFileEx(handle, buffer, 1, &ol, NULL);

    The problem is, that this call doesn’t succeed and GetLastError() returns 87 (ERROR_INVALID_PARAMETER).

What could I try to be able to read from the device?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:28:16+00:00Added an answer on May 23, 2026 at 3:28 pm

    The ReadFileEx documentation states that

    The ReadFileEx function ignores the OVERLAPPED structure’s hEvent
    member. An application is free to use that member for its own purposes
    in the context of a ReadFileEx call. ReadFileEx signals completion of
    its read operation by calling, or queuing a call to, the completion
    routine pointed to by lpCompletionRoutine, so it does not need an
    event handle.

    So although it also says that the completion routine is optional, it’s probably needed. Also note the community comment at the bottom of the page you linked to – MS may have fixed that crash by considering a NULL lpCompletionRoutine an error. However, I have not tested it to verify.

    If you are not using a completion routine you can use the normal ReadFile for your overlapped operation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to C, and want to read some data from a file.
In my grails application I want to read some values from properties file and
I would like to read some data from a stream I have using std::getline
I want to export some data from my jruby on rails webapp to excel,
I want to store some data from structures like this: class Project { ChildA
i want to show some data from DB. and i'm use ajax to do
I want to get data from a DMA enabled, PCIe hardware device into user-space
I want to send and receive some data from my server, but I don't
I am building application that required some data from iPhone's Call log(read only). The
I want to be able to occasionally programmatically grab some data from the graph

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.