Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

open the COM1 port

Posted on 1998-01-07
1
Medium Priority
?
606 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
1 Comment
 
LVL 7

Accepted Solution

by:
galkin earned 150 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

  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 …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

916 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