<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# 字符串?

        Converting C++ string/wchar_t* to C# string?(将 C++ 字符串/wchar_t* 转换为 C# 字符串?)

        <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# 字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Accessing attribute info from DTE(从 DTE 访问属性信息)
                  c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  C# Attributes and their uses(C# 属性及其用途)
                  C# - Getting all enums value by attribute(C# - 按属性获取所有枚举值)
                    <tbody id='yM6fu'></tbody>
                        <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'>