• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            天下

            記錄修行的印記

            如何:將 System::String 轉換為標準字符串

            //《精通.NET互操作:P/Invoke、C++ Interop和COM Interop》
            //ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.chs/dv_vccore/html/79e2537e-d4eb-459f-9506-0e738045b59e.htm
            // convert_system_string.cpp
            // compile with: /clr
            #include <string>
            #include <iostream>
            using namespace std;
            using namespace System;

            void MarshalString ( String ^ s, string& os ) {
               using namespace Runtime::InteropServices;
               const char* chars = 
                  (const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer();
               os = chars;
               Marshal::FreeHGlobal(IntPtr((void*)chars));
            }

            void MarshalString ( String ^ s, wstring& os ) {
               using namespace Runtime::InteropServices;
               const wchar_t* chars = 
                  (const wchar_t*)(Marshal::StringToHGlobalUni(s)).ToPointer();
               os = chars;
               Marshal::FreeHGlobal(IntPtr((void*)chars));
            }

            int main() {
               string a = "test";
               wstring b = L"test2";
               String ^ c = gcnew String("abcd");

               cout << a << endl;
               MarshalString(c, a);
               c = "efgh";
               MarshalString(c, b);
               cout << a << endl;
               wcout << b << endl;
            }

            posted on 2015-12-14 15:46 天下 閱讀(414) 評論(0)  編輯 收藏 引用 所屬分類: C/C++C#

            <2010年10月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            導航

            統計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            亚洲AV无码1区2区久久| 久久亚洲国产精品五月天婷| 久久夜色精品国产噜噜噜亚洲AV| 人妻精品久久久久中文字幕69| 久久国产精品成人影院| 久久亚洲2019中文字幕| 无码人妻久久久一区二区三区| 午夜不卡久久精品无码免费| 成人久久精品一区二区三区| 日韩十八禁一区二区久久| 精品久久久久久亚洲精品| 99久久免费只有精品国产| 久久影院午夜理论片无码| 国产美女久久精品香蕉69| 久久天天躁夜夜躁狠狠| 9999国产精品欧美久久久久久| 久久国语露脸国产精品电影| 久久最近最新中文字幕大全| 亚洲综合熟女久久久30p| 国产亚洲精久久久久久无码AV| 久久精品国产日本波多野结衣| 国产69精品久久久久99| 久久亚洲国产成人精品性色| 久久婷婷色香五月综合激情| 久久九色综合九色99伊人| 亚洲国产精品久久久久网站 | 久久精品国产乱子伦| 久久久久久无码国产精品中文字幕| 久久久av波多野一区二区| 亚洲va久久久噜噜噜久久| 久久久这里只有精品加勒比| 久久婷婷色香五月综合激情| 婷婷久久综合九色综合九七| 热RE99久久精品国产66热| 久久久久亚洲爆乳少妇无| 色婷婷久久久SWAG精品| 亚洲精品tv久久久久久久久久| 亚洲精品成人网久久久久久| 亚洲中文字幕伊人久久无码| 亚洲精品久久久www| 国产一区二区久久久|