BYTE cSendBuf1 [1024].
Memcpy (cSendBuf1, str1 GetBuffer (str1 GetLength ()), str1. GetLength ());//put cstrings in byte array
PSocket - & gt; Send (cSendBuf1, 1024, 0);
Code as above, placed in the timer has been sent the Access Violation at address is disabled and the activation of context is not activated recently,
After clicking the interrupt play to the if (m_pCtrlSite==NULL)
: : SetWindowText (m_hWnd, lpszString);
The else
M_pCtrlSite - & gt; SetWindowText (lpszString);
}
The location of the
For bosses to help look at what's the problem
CodePudding user response:
Initialize the send buffer tryBYTE cSendBuf [n].
Memset (cSendBuf, 0, sizeof (cSendBuf));
Memcpy (cSendBuf, str1 LPCTSTR, str1. GetLength () * sizeof (TCHAR));
CodePudding user response:
Seems to be out of memory, thank upstairs, but the past can only display Chinese characters into a small box is whyCodePudding user response:
May be is not the same as the sender and the receiver compilation mode? As he is UNICODE is multi-byte?Instead the unified format, or try to UTF8
CodePudding user response:
VS. Default is unicode.If your receiver is also written VS, just have a look at, whether is unicode. And remember to bring your char * buffer pointer cast TCHAR * it cstrings, assignment or cstrings will automatically do a code conversion, garbled words.
CodePudding user response:
On the top floor,,,,,,,,,,,,,,,,CodePudding user response:
See description send English no problem, the problem is out on the format of the Chinese characters, see you is the sender MBCS or unicode, as long as the receiver and the sender is consistent,CodePudding user response:
Clear code does not match theThe server side and service side to agreed a literal encoding
Not in gb2312 encoding on each side with UTF - 16 decoding
As for the length of the string how agree to also want to do
Is like a BSTR in before the string length, or end, 00 agreed upon string