Solved

open the COM1 port

Posted on 1998-01-07
1
567 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 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

832 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