• <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 轉(zhuǎn)換為標(biāo)準字符串

            //《精通.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 天下 閱讀(422) 評論(0)  編輯 收藏 引用 所屬分類: C/C++C#

            <2011年10月>
            2526272829301
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            導(dǎo)航

            統(tǒng)計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            久久久久国产视频电影| 国产产无码乱码精品久久鸭| 久久久久无码精品| 国产成人精品综合久久久久| 国产亚洲精品自在久久| 久久精品不卡| 国产精品一区二区久久国产| 国产成人精品久久亚洲| 久久精品人妻中文系列| 国产精品VIDEOSSEX久久发布| 国内精品伊人久久久久妇| 国产精品久久久久影院色| 午夜精品久久久久久影视riav| 亚洲va久久久噜噜噜久久| 久久午夜无码鲁丝片午夜精品| 久久A级毛片免费观看| 一97日本道伊人久久综合影院| 久久精品国产91久久综合麻豆自制| 中文字幕无码久久人妻| 久久99精品国产麻豆婷婷| 久久精品国产亚洲AV无码娇色 | 99久久国产免费福利| 中文字幕久久精品无码| 久久伊人中文无码| 狠狠精品久久久无码中文字幕| 性高湖久久久久久久久| 久久精品人人做人人爽电影| 色婷婷久久久SWAG精品| 久久激情亚洲精品无码?V| 91精品国产高清久久久久久91| 国产精品18久久久久久vr| 久久久久久午夜成人影院| 欧美大香线蕉线伊人久久| 久久天天躁狠狠躁夜夜躁2014| 香蕉aa三级久久毛片 | 国产成年无码久久久免费| 中文成人无码精品久久久不卡 | 国产69精品久久久久9999| 国产呻吟久久久久久久92| 国产精品欧美久久久久无广告 | 久久久久久精品无码人妻|