Hello,
I am porting an app originally written in c, to c++, and I am having difficulty converting a CString to a pointer to a character array. Please pardon all the commented out code, but I have been trying anything and everything to get this to work.
In the original app I used code from this website, with success. I am confused about if I need to use overlapped or non-overlapped. The overlapped code came from the msdn website.
When I try to use the overlapped code, I receive my data back with zero interspersed every other byte in the reply, which I expect since I am using a CString to contain the message.
I am using a loop-back connector to test the communication.
Thanks in advance.
bool ELMCommWrite(CString strDataToWrite, HANDLE hWnd)
{
OVERLAPPED osWrite = {0};
DWORD dwWritten, dwRes, dwToWrite;
BOOL fRes;
char * chDataToWrite[] = {"1234\0"};
LPCTSTR pstrDataToWrite = strDataToWrite;
dwToWrite = 5;
WriteFile(hCom, pstrDataToWrite, lstrlen(pstrDataToWrite) * sizeof(TCHAR), &dwWritten, NULL);
return 0;
}