EVC 4.2 Problem with Serial Communication
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......

