Solved

open the COM1 port

Posted on 1998-01-07
1
583 Views
Last Modified: 2008-02-01
Dear sir,
 How can I open the COM1 port to read the characters  through it by using Visual C++ 5.0?
Thanks,
0
Comment
Question by:myle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
galkin earned 50 total points
ID: 1177739
Com port is treated as file in Win32. So use CerateFile Win32 API function to open file and ReadFile and WriteFile to read/write data from/to port.

  HANDLE hPort = ::CreateFile
  ( _T("COM1"),
            GENERIC_READ | GENERIC_WRITE,
            0,    // exclusive access                
            NULL, // no security attributes
            OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL,
            NULL  // No template
  );
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question