|
카테고리
이전블로그
이글루링크
최근 등록된 덧글
궁금한데요 // 님 덕분에..
by 셀린™ at 04/09 궁금한데요 // 관심 밖. .. by 셀린™ at 03/26 혹시 찾고 있는 자료가 .. by doekhdk at 03/19 직업이 프로그래머 아니.. by 궁금한데요 at 02/27 혹시님 // MS 공식 한글 .. by 셀린™ at 12/16 혹시 MS 공식 한글 FP은.. by 혹시 at 11/25 이런 님// 해당 파일이 있.. by 셀린™ at 10/13 자세히좀 알려주세요 뭐.. by 이런 at 09/27 64비트 사용하시는 분은 .. by 셀린™ at 07/30 부연설명 해야 할 것으로.. by 셀린™ at 07/24 |
// convert_from_bstr_t.cpp
// compile with /clr /link comsuppw.lib #include <iostream> #include <stdlib.h> #include <string> #include "atlbase.h" #include "atlstr.h" #include "comutil.h" using namespace std; using namespace System; //=========================================================================== int main() //=========================================================================== { _bstr_t orig("Hello, World!"); wcout << orig << " (_bstr_t)" << endl; // Convert to a char* const size_t newsize = 100; char nstring[newsize]; strcpy_s(nstring, (char *)orig); strcat_s(nstring, " (char *)"); cout << nstring << endl; // Convert to a wchar_t* wchar_t wcstring[newsize]; wcscpy_s(wcstring, (wchar_t *)orig); wcscat_s(wcstring, L" (wchar_t *)"); wcout << wcstring << endl; // Convert to a CComBSTR CComBSTR ccombstr((char *)orig); if (ccombstr.Append(L" (CComBSTR)") == S_OK) { CW2A printstr(ccombstr); cout << printstr << endl; } // Convert to a CString CString cstring((char *)orig); cstring += " (CString)"; cout << cstring << endl; // Convert to a basic_string string basicstring((char *)orig); basicstring += " (basic_string)"; cout << basicstring << endl; // Convert to a System::String String ^systemstring = gcnew String((char *)orig); systemstring += " (System::String)"; Console::WriteLine("{0}", systemstring); delete systemstring; } 출력 Hello, World! (_bstr_t) Hello, World! (char *) Hello, World! (wchar_t *) Hello, World! (CComBSTR) Hello, World! (CString) Hello, World! (basic_string) Hello, World! (System::String) 이 글과 관련있는 글을 자동검색한 결과입니다 [?]
※ 로그인 사용자만 덧글을 남길 수 있습니다.
|