{"id":216,"date":"2014-07-23T02:40:34","date_gmt":"2014-07-23T11:40:34","guid":{"rendered":"http:\/\/blog.box.kr\/?p=216"},"modified":"2014-07-23T02:40:34","modified_gmt":"2014-07-23T11:40:34","slug":"bstr-char%ea%b0%84%ec%9d%98-%eb%b3%80%ed%99%98","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=216","title":{"rendered":"BSTR &#8211; char*\uac04\uc758 \ubcc0\ud658 \ubc0f BSTR\uc5d0 \ub300\ud574&#8230;"},"content":{"rendered":"<div class=\"titleWrap\">\n<h2 class=\"title\"><a href=\"http:\/\/kst924.tistory.com\/entry\/BSTR-char%EA%B0%84%EC%9D%98-%EB%B3%80%ED%99%98\">BSTR &#8211; char*\uac04\uc758 \ubcc0\ud658<\/a><\/h2>\n<\/div>\n<div class=\"container\"><!-- \ud3ec\uc2a4\ud2b8\uad00\ub9ac --> <!-- \ud3ec\uc2a4\ud2b8 \ubcf8\ubb38 \ub0b4\uc6a9 --><\/p>\n<div class=\"article\">#include &lt;afxconv.h&gt;void BSTRtoCHAR(char *Msg[], const BSTR conv)<br \/>\n{<br \/>\nUSES_CONVERSION;<br \/>\nstrcpy( *Msg, OLE2T(conv) );<br \/>\n}void CHARtoBSTR( BSTR *Msg, const char *conv )<br \/>\n{<br \/>\nUSES_CONVERSION;<br \/>\n*Msg = T2OLE(conv);<\/p>\n<p>\/\/ *Msg = SysAllocString( A2W(conv) );<br \/>\n}<\/p>\n<ol class=\"linenums\">\n<li class=\"L3\"><code class=\"language-cpp\"><span class=\"pln\">\u00a0strText<\/span><span class=\"pun\">=<\/span><span class=\"typ\">SysAllocStringLen<\/span><span class=\"pun\">(<\/span><span class=\"pln\">szOleChar<\/span><span class=\"pun\">,<\/span><span class=\"pln\">iLen<\/span><span class=\"pun\">); \u00a0 \/\/ BSTR\uc5d0 \uacf5\uac04 \ud560\ub2f9..<\/span><\/code><\/li>\n<li class=\"L4\"><code class=\"language-cpp\"><span class=\"pln\"> printf<\/span><span class=\"pun\">(<\/span><span class=\"str\">\"SysStringLen(strText) = %un\"<\/span><span class=\"pun\">,<\/span><span class=\"typ\">SysStringLen<\/span><span class=\"pun\">(<\/span><span class=\"pln\">strText<\/span><span class=\"pun\">)); \u00a0 \u00a0\/\/ BSTR String\uc758 Length<\/span><\/code><\/li>\n<li class=\"L4\"><\/li>\n<\/ol>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>BSTR &#8211; char*\uac04\uc758 \ubcc0\ud658 #include &lt;afxconv.h&gt;void BSTRtoCHAR(char *Msg[], const BSTR conv) { USES_CONVERSION; strcpy( *Msg, OLE2T(conv) ); }void CHARtoBSTR( BSTR *Msg, const char *conv ) { USES_CONVERSION; *Msg = T2OLE(conv); \/\/ *Msg = SysAllocString( A2W(conv) ); } \u00a0strText=SysAllocStringLen(szOleChar,iLen); \u00a0 \/\/ BSTR\uc5d0 \uacf5\uac04 \ud560\ub2f9.. printf(&#8220;SysStringLen(strText) = %un&#8221;,SysStringLen(strText)); \u00a0 \u00a0\/\/ BSTR String\uc758 Length<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"ngg_post_thumbnail":0,"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[9,19,7],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-3u","jetpack-related-posts":[{"id":441,"url":"https:\/\/blog.box.kr\/?p=441","url_meta":{"origin":216,"position":0},"title":"CStirng \u2194 char * (Unicode \u2194 ANSI)","date":"2014-12-15","format":false,"excerpt":"\u203b\u00a0Format \uc9c0\uc815 \uac00\ub2a5 (CString \u2192 char *) \/\/\u00a0Static CString strText = _T(\"casting test\"); char szText[128]; sprintf_s(szText, 128, \"%S\", strText); \/\/ Using\u00a0szText... \/\/ Dynamic CString strText = _T(\"casting test\"); const size_t size = strText.GetLength(); char *pszText = new char[size]; sprintf_s(pszText,\u00a0size, \"%S\", strText); \/\/ Using\u00a0pszText... \/\/ \ub625 \uce58\uc6b0\ub294 \uac70 \uc78a\uc9c0\ub9d0\uc790 delete\u00a0pszText; \u203b\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":230,"url":"https:\/\/blog.box.kr\/?p=230","url_meta":{"origin":216,"position":1},"title":"std::string \ub2e4\ub8e8\uae30.. ( \ucc3e\uae30, \uacf5\ubc31\uc81c\uac70 \ub4f1\ub4f1)","date":"2014-07-23","format":false,"excerpt":"\ubb38\uc790\uc5f4 string #include \"StdAfx.h\" #include \"StringTest.h\" #include <algorithm> \/\/transform \uc0ac\uc6a9 #include <functional> \/\/bind1st using std::string; \/\/ \uc774\ub807\uac8c \uc9c0\uc815\ud574\uc900\ub2e4. StringTest::StringTest() { log(\"StringTest \uc0dd\uc131\uc790 \ud638\ucd9c\"); } StringTest::~StringTest(void) { log(\"StringTest \uc18c\uba78\uc790 \ud638\ucd9c\"); } void StringTest::test() { log(\"============ string class ==========\"); \/\/ \uc0dd\uc131\uc790 \u00a0 std::string s0; \/\/ \ube44\uc5b4\uc788\ub294 string std::string s1(\"012345\",3); \/\/ \uacb0\uacfc: 012\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":252,"url":"https:\/\/blog.box.kr\/?p=252","url_meta":{"origin":216,"position":2},"title":"[\uac1c\ubc1c\/VC++] URLEncode, URLDecode, UTF8 \ubcc0\ud658 \uc18c\uc2a4","date":"2014-07-23","format":false,"excerpt":"[\uac1c\ubc1c\/VC++] URLEncode, URLDecode, UTF8 \ubcc0\ud658 \uc18c\uc2a4 IT\/\uac1c\ubc1c\u00a02011\/02\/10 12:05 [\uac1c\ubc1c\/VC++] URLEncode, URLDecode, UTF8 \ubcc0\ud658 \uc18c\uc2a4 \uc544\ub798 \uc18c\uc2a4\ub294 \uba40\ud2f0\ubc14\uc774\ud2b8 \ubb38\uc790\uc9d1\ud569 \ud504\ub85c\uc81d\ud2b8 \uc124\uc815\uc73c\ub85c \uc791\uc5c5\ud574\uc57c \uc791\ub3d9\ub41c\ub2e4. inline BYTE toHex(const BYTE &x) { return x > 9 ? x + 55: x + 48; } CString URLEncode(CString sIn) { CString sOut; const int nLen =\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":391,"url":"https:\/\/blog.box.kr\/?p=391","url_meta":{"origin":216,"position":3},"title":"[\ud38c][android] GCM (2) \u2013 \ud074\ub77c\uc774\uc5b8\ud2b8 \ub9cc\ub4e4\uae30","date":"2014-09-15","format":false,"excerpt":"\uc774\uc804 \uae00\uc5d0\uc11c \uc774\uc5b4\uc9d0 \u00a0 Google Play Service \uc5f0\uacb0\ud558\uae30 \uc774\ud074\ub9bd\uc2a4 \u2013 Windows \u2013 Android SDK Manager \ub97c \uc5f0\ub2e4. \ubaa9\ub85d\uc758 \uc81c\uc77c \uc544\ub798\ucabd\uc5d0\u00a0Goole Play Services\u00a0\uc120\ud0dd\ud55c\ub2e4. \uc624\ub978\ucabd \uc544\ub798\uc758 Install \ubc84\ud2bc\uc744 \ub204\ub978\ub2e4. \uc124\uce58\uac00 \ub05d\ub098\uba74 \uc774\ud074\ub9bd\uc2a4\uc758 \ud504\ub85c\uc81d\ud2b8 \ubaa9\ub85d\uc5d0\uc11c \uc624\ub978\ucabd \ud074\ub9ad\ud574\uc11c import \uba54\ub274\ub97c \uc120\ud0dd\ud558\uace0,{sdk}\/extras\/google\/google_play_services\/ \ub97c \uc120\ud0dd\ud55c\ub2e4. \uc791\uc131\ud560 \ud504\ub85c\uc81d\ud2b8\uc758 \uc624\ub978\ucabd \ud074\ub9ad \uba54\ub274 \u2013 properties \u2013 Android \u2013 Library\u2026","rel":"","context":"In &quot;\ucc38\uace0\ub97c \uc704\ud55c \uc800\uc7a5\ubb3c&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":220,"url":"https:\/\/blog.box.kr\/?p=220","url_meta":{"origin":216,"position":4},"title":"VARIANT to std::string","date":"2014-07-23","format":false,"excerpt":"Here's one way, not necessarily the best. In general, std::string doesn't play very well with VARIANT. #include <comutil.h> #include <string> std::string from_variant(VARIANT& vt) { _bstr_t bs(vt); return std::string(static_cast<const char*>(bs)); } void to_variant(const std::string& str, VARIANT& vt) { _bstr_t bs(str.c_str()); reinterpret_cast<_variant_t&>(vt) = bs; } \u00a0 \ub610\ud55c.. VARIANT\uac00 \ube44\uc5b4 \uc788\ub294\uc9c0 \ud655\uc778 \ud558\ub294\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":263,"url":"https:\/\/blog.box.kr\/?p=263","url_meta":{"origin":216,"position":5},"title":"[MFC] CEdit \uc5d0\uc11c Enter\ub97c \ud1b5\ud55c \uc904\ubc14\uafc8 \uc801\uc6a9","date":"2014-07-26","format":false,"excerpt":"<\ucd9c\ucc98>\u00a0http:\/\/mainia.tistory.com\/599 CEdit\u00a0\ucee8\ud2b8\ub864\uc744 \uc0ac\uc6a9\ud574 \ud55c\uc904\uc774 \uc544\ub2cc \uc5ec\ub7ec\uc904\uc758 \uba40\ud2f0\ub77c\uc778 \uae00\uc744 \uc4f8\uc218 \uc788\ub3c4\ub85d \uc124\uc815\ud574\uc57c \ud560 \ub54c\uac00 \uc788\ub2e4. Properties\u00a0\u00a0\uc5d0\uc11c\u00a0Mutility Line\u00a0\uc73c\ub85c \ubcc0\uacbd\ud55c\ub2e4\uace0 \ud574\uc11c \uc124\uc815\uc774 \ub05d\ub098\ub294 \uac83\uc740 \uc544\ub2c8\ub2e4.\u00a0\uc544\ub798\uc758 \ub0b4\uc6a9\uc744 \ucc38\uace0 \ud558\uae30 \ubc14\ub780\ub2e4. \u00a0 CEdit\u00a0\ubc15\uc2a4\uc5d0\u00a0Enter\u00a0\ud0a4\ub97c \ub20c\ub800\uc744\ub54c \uc904\ubc14\uafc8\uc744 \uc801\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 \uc6b0\uc120 PreTranslateMessage\u00a0\ub97c\u00a0overriding\u00a0\ud574\uc57c\ud55c\ub2e4.\u00a0\u00a0MSG\u00a0\uac12\uc911 WM_KEYDOWN\u00a0\uc640\u00a0VK_RETURN\u00a0\uc774\u00a0Enter\u00a0\uc5d0 \ud574\ub2f9\ud55c\ub2e4. \uadf8\ub9ac\uace0\u00a0Edit\u00a0\ubc15\uc2a4\uc5d0\u00a0Focus\u00a0\uac00 \uc788\ub294\uc9c0 \ud310\ub2e8\ud574\uc11c \uc904\ubc14\uafc8\uc744 \uc801\uc6a9\ud55c\ub2e4. BOOL CHelloDlg::PreTranslateMessage(MSG* pMsg)\u00a0 { \u00a0\u00a0\u00a0\u00a0if\u00a0(pMsg->message == WM_KEYDOWN && pMsg->wParam\u2026","rel":"","context":"In &quot;C\/C++&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/216"}],"collection":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=216"}],"version-history":[{"count":0,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}