Reopening: Serial Port Programming

For one of my application I need to access the serial port of the PPC(I have a Compaq Aero 2180 having win CE 2.11) .I tried opening the port using the CreateFile statement, but it gave me an error saying
INVALID_HANDLE_VALUE. I tried running the program on the device as well as in emulation . It failed on both. In emulation I did kill  the NT serial drivers and started the CE ones(i.e NET STOP SERIAL and then NET START WCEEMULD), but that didnt help either. I used GetLastError() and the value it returned was 2(i.e The system cannot find the file specified).the code goes something like this.
                  LPCTSTR comport;
                  HANDLE h;
                  comport =TEXT("COM1:");
                  // open port for I/O
                  h = CreateFile(comport,
Also tried writng it as
 h = CreateFile(TEXT("COM1:"),
 After this, the h is simply "INVALID_HANDLE_VALUE", which means it failed to open the port. Can anyone suggest where I am doing it  wrong. Do I need to make any changes in the registry settings? Any help will be greatly appreciated .
Who is Participating?
alespConnect With a Mentor Commented:

I am using serial port on Palm-sizePC Casio E-105 and I use next code for opening COM port:

CString comport = "COM1:";

h = CreateFile((LPCTSTR)comport,
                0, NULL,
                0, NULL);

 I hope this will help you solve you problem.

Best regards
nthotaAuthor Commented:
Thanks for the suggestion.I guess there was some problem with my device then. I used the same code that I posted  and it worked well

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.