본문 바로가기
삽질기초/SW

CString LPSTR WCHAR*

by @가을바람 2009. 8. 30.

CString to LPSTR

 Collapse
CString str = _T("My String");
int nLen = str.GetLength();
LPTSTR lpszBuf = str.GetBuffer(nLen);
// here do something with lpszBuf...........

str.ReleaseBuffer();
LPTSTR to LPWSTR
 Collapse
int nLen = MultiByteToWideChar(CP_ACP, 0, lptStr, -1, NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, lptStr, -1, lpwStr, nLen);

CString to WCHAR*
 Collapse
CString str = "A string here" ;
LPWSTR lpszW = new WCHAR[255];

LPTSTR lpStr = str.GetBuffer( str.GetLength() );
int nLen = MultiByteToWideChar(CP_ACP, 0,lpStr, -1, NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, lpStr, -1, lpszW, nLen);
AFunctionUsesWCHAR( lpszW );
delete[] lpszW;


시리얼 프로그램 짜다가 찾음.





Data conversions with small examples

'삽질기초 > SW' 카테고리의 다른 글

c# 전역 비트맵. 다시그리기.  (0) 2009.11.04
C# 기본 그래픽  (0) 2009.11.04
.NET Framework의 개요  (0) 2009.08.30
serial commution  (0) 2009.08.29
[MFC] Tips  (0) 2009.05.13