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

            <2015年12月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            亚洲精品午夜国产VA久久成人| 精品国产VA久久久久久久冰 | 99久久免费只有精品国产| 久久99国内精品自在现线| 999久久久免费国产精品播放| 日韩中文久久| 72种姿势欧美久久久久大黄蕉| 国产亚洲成人久久| 久久久久久亚洲Av无码精品专口| 色噜噜狠狠先锋影音久久| 久久国内免费视频| 国产精品成人久久久久三级午夜电影| 久久精品综合网| 久久综合伊人77777麻豆| 精品国产福利久久久| 亚洲色婷婷综合久久| 久久综合九色综合欧美就去吻| 成人资源影音先锋久久资源网| 久久精品国产99国产精品导航 | 久久Av无码精品人妻系列| 久久这里的只有是精品23| 国产福利电影一区二区三区久久久久成人精品综合 | 伊人久久国产免费观看视频| 久久久91精品国产一区二区三区 | 久久久久成人精品无码中文字幕| 思思久久99热免费精品6| 狠狠色综合久久久久尤物| 久久精品成人免费网站| www久久久天天com| 久久午夜伦鲁片免费无码| 亚洲中文字幕久久精品无码喷水 | 国产成人无码精品久久久免费| 欧美精品久久久久久久自慰| 中文字幕无码免费久久| 一本一本久久a久久综合精品蜜桃 一本一道久久综合狠狠老 | 久久综合视频网站| 亚洲а∨天堂久久精品| 久久国产欧美日韩精品免费| 久久福利资源国产精品999| 久久精品卫校国产小美女| 无码专区久久综合久中文字幕|