Search

'전체 글'에 해당되는 글 113건

  1. 2005.08.05 About String

About String

Program C/C++ 2005. 8. 5. 17:14 Posted by HisPark
String String .......

Sample code
CString cs;
BSTR bstr;
WCHAR wsz[81];
CComBSTR cbstr;
char sz[81];
TCHAR tsz[81];
basic_string bs;
_bstr_t _bstr;

USES_CONVERSION;
    
// Convert CString to various types
cs = "String1";
bstr = cs.AllocSysString();   // BSTR    
_tcscpy(tsz, (LPCTSTR)cs);    // LPCTSTR
strcpy(sz, T2A(tsz));       // ANSI string
wcscpy(wsz, bstr);         // wide string
cbstr = bstr;             // CComBSTR via
bs = sz;                // STL string
_bstr = (LPCTSTR) cs;       // _bstr_t via either
                     //   operator=(const char*) or
                     //   operator=(const wchar_t*)
                     //   if _UNICODE is defined.
::SysFreeString(bstr);

// Convert BSTR to various types
bstr = ::SysAllocString(L"String2");
cs = bstr;               // CString via its LPCWSTR ctor
wcscpy(wsz, bstr);         // Unicode
cbstr = bstr;             // CComBSTR via operator=(LPOLESTR)
strcpy(sz, W2A(bstr));       // ANSI string
bs = sz;                // STL string operator=(const T*)
_tcscpy(tsz, W2T(bstr));     // LPTSTR
_bstr = bstr;             // _bstr_t via operator=(const wchar_t*)
::SysFreeString(bstr);

참조링크
http://www.hal-pc.org/%7Eabeld/cppsighal/vcppstrings.htm#Sample
http://www.oreilly.com/catalog/win32api/chapter/ch06.html
http://www.whooper.co.uk/excelvariants.htm

'Program C/C++' 카테고리의 다른 글

Class 내부 Thread basic...  (1) 2013.05.10
typedef...  (0) 2011.09.26
c 표준 함수들  (0) 2011.06.24
문자열 타입 변환 | C & C++  (0) 2010.10.13
C++의 다양한 string 타입 | C & C++  (0) 2010.01.30