• <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>

            天下

            記錄修行的印記

            如何:使用 C++ Interop 封送 Unicode 字符串

            // MarshalUnicode1.cpp
            // compile with: /clr
            #include <iostream>
            #include <stdio.h>
            #include <vcclr.h>

            using namespace std;

            using namespace System;
            using namespace System::Runtime::InteropServices;

            #pragma unmanaged

            void NativeTakesAString(const wchar_t* p) {
               printf_s("(native) recieved '%S'\n", p);
            }

            #pragma managed
             
            int main() {
               String^ s = gcnew String("test string");
               pin_ptr<const wchar_t> str = PtrToStringChars(s);

               Console::WriteLine("(managed) passing string to native func");
               NativeTakesAString( str );
            }
             

            下面的示例演示在非托管函數調用的托管函數中訪問 Unicode 字符串時需要的數據封送處理。一旦托管函數接收到本機 Unicode 字符串,就會使用 PtrToStringUni 方法將其轉換為托管字符串。

              復制代碼 
            // MarshalUnicode2.cpp
            // compile with: /clr
            #include <iostream>

            using namespace std;
            using namespace System;
            using namespace System::Runtime::InteropServices;

            #pragma managed

            void ManagedStringFunc(wchar_t* s) {
               String^ ms = Marshal::PtrToStringUni((IntPtr)s);
               Console::WriteLine("(managed) recieved '{0}'", ms);
            }

            #pragma unmanaged

            void NativeProvidesAString() {
               cout << "(unmanaged) calling managed func\n";
               ManagedStringFunc(L"test string");
            }

            #pragma managed

            int main() {
               NativeProvidesAString();
            }
             

            posted on 2015-12-01 11:09 天下 閱讀(233) 評論(0)  編輯 收藏 引用

            <2013年3月>
            242526272812
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            導航

            統計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            囯产极品美女高潮无套久久久| 精品熟女少妇aⅴ免费久久| 午夜精品久久久久久影视riav| 四虎影视久久久免费| 一本色道久久综合亚洲精品| 97久久精品无码一区二区| 精品水蜜桃久久久久久久| 伊人久久大香线蕉综合影院首页| 999久久久免费精品国产| 亚洲欧美另类日本久久国产真实乱对白 | 性高湖久久久久久久久AAAAA| 女人高潮久久久叫人喷水| 久久久青草久久久青草| 色偷偷88888欧美精品久久久| 久久97精品久久久久久久不卡| 亚洲国产成人久久一区WWW| 久久精品国产亚洲AV大全| 中文字幕亚洲综合久久菠萝蜜| 精品久久一区二区| 2021国产精品午夜久久| 国产99久久久久久免费看| 99精品久久久久中文字幕| 囯产极品美女高潮无套久久久| 久久影视国产亚洲| 久久久久亚洲AV综合波多野结衣| 久久久久久免费一区二区三区| 人妻丰满AV无码久久不卡| 无码人妻久久久一区二区三区| 久久天天躁狠狠躁夜夜2020老熟妇| a级成人毛片久久| 2021久久国自产拍精品| 久久综合88熟人妻| 精品久久久久久亚洲精品| 精品免费久久久久久久| 国产91久久精品一区二区| 国产精品久久久久久久久鸭 | 久久久噜噜噜久久中文福利| 亚洲欧美成人综合久久久| 国产毛片欧美毛片久久久| 久久天天躁狠狠躁夜夜96流白浆 | 亚洲AV无码久久精品狠狠爱浪潮|