<small id='Zyqlj'></small><noframes id='Zyqlj'>

    <bdo id='Zyqlj'></bdo><ul id='Zyqlj'></ul>

  • <legend id='Zyqlj'><style id='Zyqlj'><dir id='Zyqlj'><q id='Zyqlj'></q></dir></style></legend>
    <tfoot id='Zyqlj'></tfoot>
  • <i id='Zyqlj'><tr id='Zyqlj'><dt id='Zyqlj'><q id='Zyqlj'><span id='Zyqlj'><b id='Zyqlj'><form id='Zyqlj'><ins id='Zyqlj'></ins><ul id='Zyqlj'></ul><sub id='Zyqlj'></sub></form><legend id='Zyqlj'></legend><bdo id='Zyqlj'><pre id='Zyqlj'><center id='Zyqlj'></center></pre></bdo></b><th id='Zyqlj'></th></span></q></dt></tr></i><div id='Zyqlj'><tfoot id='Zyqlj'></tfoot><dl id='Zyqlj'><fieldset id='Zyqlj'></fieldset></dl></div>

        将 C++ 字符串/wchar_t* 转换为 C# 字符串?

        时间:2023-07-25

        <i id='iYlhX'><tr id='iYlhX'><dt id='iYlhX'><q id='iYlhX'><span id='iYlhX'><b id='iYlhX'><form id='iYlhX'><ins id='iYlhX'></ins><ul id='iYlhX'></ul><sub id='iYlhX'></sub></form><legend id='iYlhX'></legend><bdo id='iYlhX'><pre id='iYlhX'><center id='iYlhX'></center></pre></bdo></b><th id='iYlhX'></th></span></q></dt></tr></i><div id='iYlhX'><tfoot id='iYlhX'></tfoot><dl id='iYlhX'><fieldset id='iYlhX'></fieldset></dl></div>

        <small id='iYlhX'></small><noframes id='iYlhX'>

        1. <legend id='iYlhX'><style id='iYlhX'><dir id='iYlhX'><q id='iYlhX'></q></dir></style></legend>

              • <bdo id='iYlhX'></bdo><ul id='iYlhX'></ul>
                    <tbody id='iYlhX'></tbody>

                  <tfoot id='iYlhX'></tfoot>

                • 本文介绍了将 C++ 字符串/wchar_t* 转换为 C# 字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  问题:我需要从 C++ 可执行文件中调用 C# dll.我使用 COM,它适用于 int、long 和 bool.但我无法得到一个字符串...

                  Question: I need to call a C# dll from a C++ executable. I use COM, and it works fine for int, long and bool. But I can't get a string along...

                  IDL 文件说它是一个 BSTR,但我无法正确传递它,也没有检索到它.我尝试像使用 VB6 一样使用 wchar_t* 和 sysalloc,但这似乎不起作用.

                  The IDL file says it's a BSTR, but I can't pass it correctly, and neither retrieve one. I tried using wchar_t* and using sysalloc as I did with VB6, but that doesn't seem to work.

                  任何人都知道怎么做,或者可能出了什么问题?

                  Anybody knows how, or what might be wrong ?

                  推荐答案

                  如果你使用 ATL,你可以这样做:

                  If you're using ATL you can do this:

                  std::string theString = "hello";
                  CComBSTR bstr(theString.c_str());
                  DoSomething(bstr);  // Function that takes a BSTR as an argument
                  

                  或者如果没有 ATL:

                  Or if no ATL:

                  const wchar_t* theString = L"hello";
                  BSTR bstr = SysAllocString(theString);
                  DoSomething(bstr);
                  SysFreeString(bstr);
                  

                  这篇关于将 C++ 字符串/wchar_t* 转换为 C# 字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:从 C# 调用托管 C# COM 对象 下一篇:c# 类的属性在 Visual Basic 6.0 中不可见

                  相关文章

                    <legend id='yM6fu'><style id='yM6fu'><dir id='yM6fu'><q id='yM6fu'></q></dir></style></legend>

                    1. <i id='yM6fu'><tr id='yM6fu'><dt id='yM6fu'><q id='yM6fu'><span id='yM6fu'><b id='yM6fu'><form id='yM6fu'><ins id='yM6fu'></ins><ul id='yM6fu'></ul><sub id='yM6fu'></sub></form><legend id='yM6fu'></legend><bdo id='yM6fu'><pre id='yM6fu'><center id='yM6fu'></center></pre></bdo></b><th id='yM6fu'></th></span></q></dt></tr></i><div id='yM6fu'><tfoot id='yM6fu'></tfoot><dl id='yM6fu'><fieldset id='yM6fu'></fieldset></dl></div>
                    2. <tfoot id='yM6fu'></tfoot>
                      • <bdo id='yM6fu'></bdo><ul id='yM6fu'></ul>

                      <small id='yM6fu'></small><noframes id='yM6fu'>