VC++의 문자열 변환중 CString에 관련된 몇가지를 알아보자.
CString LPSTR WCHAR* LPCWSTR
CString to LPSTR
CollapseCString str = _T("My String");
int nLen = str.GetLength();
LPTSTR lpszBuf = str.GetBuffer(nLen);
// here do something with lpszBuf...........
str.ReleaseBuffer();
LPTSTR to LPWSTR
int nLen = MultiByteToWideChar(CP_ACP, 0, lptStr, -1, NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, lptStr, -1, lpwStr, nLen);
CString to WCHAR*
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;
CString to LPCWSTR
CString a;
a.Format(_T("%d"), nDiffTime);
WCHAR *b;
b = a.GetBuffer(a.GetLength());
'IT-개발,DB' 카테고리의 다른 글
[개발/웹] VC++ ATL을 이용한 Scriptable ActiveX 제작 (0) | 2010.09.13 |
---|---|
[C#] best practice is to write a BHO which will load your BandObject. (0) | 2010.09.10 |
c# delay 함수 / C# Delay function (0) | 2010.09.10 |
[VC#] C++로 만든 DLL 을 C#에서 사용하기 (0) | 2010.09.10 |
[Win32] ActiveX 컨트롤 등록 (0) | 2010.09.08 |
댓글