获取c#输出字符串参数值为c++ BSTR*
Get C# out string paramater value to C++ BSTR*?
我有一个方法在c# DLL有一个输入和两个输出参数。
我想从firebreath c++中调用该函数。我如何从c++中传递BSTR*值?我如何从c#中得到这些值?
我已经试过使用
BSTR* userKey =NULL;
*userKey = ::SysAllocString(L"Hello Managed World");
但是它不工作。
c#功能:public void GetPublicKeyforEncryption(String ToUserEmailAddress, out String userKey , out String mySharedKey)
调用函数:
std::wstring& ToUserEmailaddress;
BYTE **bEncryptData = NULL;
BSTR bsData = SysAllocStringLen(ToUserEmailaddress.data(), ToUserEmailaddress.size());
BSTR* userKey =NULL;
BSTR* mySharedKey =NULL;
CSharpInterface->GetPublicKeyforEncryption(bsData,userKey ,mySharedKey );
在上面的c++ getpublickeyforencryptionbsdata值被正确传递,我将如何分配内存和传递
userKey ,mySharedKey in the BSTR* type
谁能解决这个问题?帮助我。
谢谢桑珠抱
这不是正确的代码,BSTR已经是指针类型。您需要传递一个指向BSTR变量的指针,以便被调用的方法可以对其进行赋值。假设只有一个out string
参数的泛型代码:
BSTR retval = NULL;
HRESULT hr = CSharpInterface->SomeMethod(&retval);
if (SUCCEEDED(hr)) {
// Use retval
//...
SysFreeString(retval);
}
相关文章:
- 随机字符,从强制转换 Arduino 字符串到 Excel BSTR 通过 c++ DLL
- 如何将 CComVariant bstr 转换为 CString
- 如何使用消息框函数显示 BSTR 值
- 如何解决此错误(将WCHAR_T转换为BSTR)
- 如何序列化变体或 BSTR
- C++函数返回无法调用 SysFreeString() 的函数的 BSTR
- 从 VBA 中的 (c++ BSTR) 字符串中删除 chr(0)
- 如何返回包含来自com dll的多个空字符的BSTR
- BSTR到WSTRING的内存泄漏
- 用于unordered_set<BSTR>的 Hash & EqualTo 函数
- 我可以在输入BSTR变体上调用variantChangeType吗?
- C++用于连接两个 Bstr 字符串的代码
- 将 BSTR 转换为 BYTE 数组C++
- 如何在Visual C 中的BSTR和32位Unicode字符串之间进行转换
- 将 BSTR 转换为 CString 时出错
- 如何在Visual Studio C++2010中将BSTR转换为std::string
- C++ STL 地图:BSTR 的问题
- BSTR 中有 Unicode 符号吗?
- 将BSTR HEXA小数线转换为C 中的字节 *
- 为什么BSTR以及如何将其转换为QString