EVC 4.2 Problem with Serial Communication

Hello all,

I am writing Pocket PC serial communication application using eVC 4.2 with Pocket PC 2003 Emulator.

Using eVC i created a new Project(WCE Pocket PC 2003 Application) and i selected the Empty Project Option.
The following is the code which i have written in .cpp file

#include "windows.h"

int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,LPWSTR lpCmdLine,int nCmdShow)
{
HANDLE hSer;

hSer=CreateFile(TEXT(COM1:"),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);

if(hSer==INVALID_HANDLE_VALUE)
MessageBox(NULL,TEXT ("Port is not opened"),TEXT("Hello1"),MB_OK);
else
MessageBox(NULL,TEXT ("Port opened suceefully"),TEXT("Hello1"),MB_OK);
DCB dcb;
dcb.DCBlength=sizeof(dcb);
GetCommState(hSer,&dcb);
dcb.BaudRate=9600;
if(SetCommState(hSer,&dcb))

MessageBox(NULL,TEXT ("Port is opened with baud rate 9600"),TEXT("Hello1"),MB_OK);

INT rc;

BYTE szText[10]={0x41,0x42,0x43,0x44,0x45};
BYTE szText1[20];
DWORD cBytes;

PurgeComm(hSer,PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR);

rc = WriteFile (hSer, szText,
sizeof (szText),&cBytes, 0);

if(rc)

MessageBox(NULL,TEXT("Port write is success full"),TEXT("Hello1"),MB_OK);
DWORD bytesRead;

if(rc =ReadFile(hSer,szText1,sizeof(szText1),&bytesRead ,0))

MessageBox(NULL,TEXT("Port read is success full"),TEXT("Hello1"),MB_OK);

CloseHandle(hSer);
}

The above code is working fine with Pocket PC 2003 Emulator and i am able to see the bytes i have sent on Hyperteminal of another PC connected with my PC through Null Modem.

If i select in the Project option "A simple Windows CE application" instead of "A Empty Project" and write same code in WinMain function , i am not able to see the bytes sent on HyperTerminal even though WriteFile is Successful. The same thing is Happening if write above code in a DLL or Static Library and call from a Windows CE Application.

Any idea why it is Happening Like this ?
Thanks for Help......
[2217 byte] By [gururaja23] at [2007-11-20 10:17:15]
# 1 Re: EVC 4.2 Problem with Serial Communication
Edit your post using code tags (see faq). Your not setting up dcb (only baud) so maybe you have hardware handshake set as default.
S_M_A at 2007-11-9 12:40:19 >
# 2 Re: EVC 4.2 Problem with Serial Communication
How to do Asyncronous IO Communication in Windows CE? any idea on this...............

How to use Rs232 API's without overlapped structure in Windows CE?
gururaja23 at 2007-11-9 12:41:20 >
# 3 Re: EVC 4.2 Problem with Serial Communication
Maybe this thread can help you http://www.dev-archive.com/forum/showthread.php?t=407985
S_M_A at 2007-11-9 12:42:14 >