'BSTR to CString'에 해당되는 글 1건

  1. 2018.06.07 CString <-> BSTR (Unicode , Multibyte)

인터넷 대부분의 글에는 현재 프로젝트 환경이 Multibyte인지 Unicode인지 명시가 되어있지 않아


형변환 하기 힘든 경우가 많아서 작성한 글.. 이 예제는 Visual Studio 2013 MFC환경에서 제작되었음.




BSTR to CString


 

 BSTR to CString

 MultiByte

1
2
3
CString strTest = "QWERT";
BSTR szTest = strTest.AllocSysString();
CString strTest2 = (CString)szTest;
cs

 Unicode

1
2
BSTR szTest;
CString strTest2 = (CString)szTest;
cs



CString to BSTR


 

 CString to BSTR

MultiByte

1
2
CString strTest = "QWERT";
BSTR szTest = strTest.AllocSysString();
cs

 Unicode 

 

1
2
CString strTest = _T("QWERT");
BSTR szTest = strTest.AllocSysString();
cs


Unicode 및 Multibyte 둘다 동일하게 사용가능하다.

'C++ > 형변환' 카테고리의 다른 글

CString <-> Const char *  (0) 2020.01.09
CString <-> LPWSTR  (0) 2018.10.10
CString <-> short * (Unicode, Multibyte), PLC ASCII  (0) 2018.06.08
CString <-> LPCTSTR  (0) 2018.05.29
Posted by 람뫼
: