Writing to Infra red/COM port using Embedded C++

Posted on 2003-04-01
Medium Priority
Last Modified: 2013-12-27
Hi Guys,
Has anyone any pointers or know any web links with sample code for writing data to Infra Red Port or any of the COM ports on Pocket PC.

For Example to have a screen with a text box on it and to print the contents of the Text Box to an Infra Red printer


B Cunney
Question by:Barry Cunney
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

Accepted Solution

abelblaine111 earned 200 total points
ID: 8256977
Here is a link with some code for you.


and here is some basic sample code for the pocket pc.  m_hCommPort is a HANDLE defined in the class

char* str = "";
DWORD numWrite;
DWORD numRead;
BOOL success = FALSE;

m_hCommPort = CreateFile(
     0,// comm devices must be opened w/exclusive-access
     NULL,      // no security attributes
     OPEN_EXISTING,//comm devices must use OPEN_EXISTING
     0,     // not overlapped I/O
     NULL   // hTemplate must be NULL for comm devices
     if (m_hCommPort == INVALID_HANDLE_VALUE)
        AfxMessageBox(TEXT("Invalid Handle Value"));
     strcpy(str, "s");

     success = WriteFile(m_hCommPort, str, strlen(str), &numWrite, 0);
     if (!success)
          AfxMessageBox(TEXT("error in Write File"));
     Sleep(3000); //Delay for transmissionsuccess =

     char str2[65530];
     ReadFile(m_hCommPort, str2, 65530, &numRead, 0);
     if (!success)
          AfxMessageBox(TEXT("Error in Read File"));
          CString j(numRead);

Hope those help.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator (https://www.appcelerator.com/). This article presumes a wor…
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 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