Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用BSTR数据类型时出错_C++_Bstr_Firebreath_Type Conversion - Fatal编程技术网

C++ 使用BSTR数据类型时出错

C++ 使用BSTR数据类型时出错,c++,bstr,firebreath,type-conversion,C++,Bstr,Firebreath,Type Conversion,我的firebreath插件项目有一个活动X控件的包装类 其中一个方法将BSTR数据类型变量作为输入,但是当我尝试调用该方法并传递BSTR时,我得到了一个错误 我甚至包括了“WTypes.h”头文件。但这似乎无法解决问题 所以有人提出了一个替代方案 short MakeCall (BSTR sNumber,short * nConnectionId ); Makecall函数使用这些参数调用由activex控件实现的Makecall函数 错误 Error 1 error C2665:

我的firebreath插件项目有一个活动X控件的包装类

其中一个方法将BSTR数据类型变量作为输入,但是当我尝试调用该方法并传递BSTR时,我得到了一个错误

我甚至包括了“WTypes.h”头文件。但这似乎无法解决问题

所以有人提出了一个替代方案

short MakeCall (BSTR sNumber,short * nConnectionId );
Makecall函数使用这些参数调用由activex控件实现的Makecall函数

错误

Error   1   error C2665: 'FB::variant_detail::conversion::convert_variant' : none of the 5 overloads could convert all the argument types   c:\users\research\downloads\firebreath-firebreath-firebreath-1.6.0rc1-15-g411c7fe\firebreath-firebreath-411c7fe\src\scriptingcore\variant.h 842 1   axWrapper
PS:在我搜索了错误后,我发现fire breath不支持宽字符,即uni代码。那么,有没有一种方法可以在FireSpreat中使用unicode数据类型呢
#include <atlbase.h>

应该这样做

该错误表示您正在尝试将FB::variant转换为BSTR,而FB::variant不知道如何做。这很可能意味着您正试图将BSTR用作在JSAPIAuto对象上注册的方法中的类型。JSAPIAuto将自动转换类型,但您必须使用它能够理解的类型,BSTR不是其中之一

相反,查找注册为JSAPI方法的任何方法,并将BSTR更改为std::wstring;然后将WSTR转换为BSTR。这应该行得通

FireBreath确实支持unicode;您可以将std::wstring用于宽字符,来自浏览器的std::字符串类型将为UTF8。您可以#包括“utf8_tools.h”,并使用FB::utf8_to_wstring和FB::wstring_to_utf8在它们之间进行转换


希望这有帮助

@Taxilian我想你可以帮我发布代码吗?@Luchian Grigore我添加了使用BSTR数据类型的函数声明,你还需要发布你得到的错误“当我试图在我的类中将变量声明为BSTR时,我得到了一个错误。”请包括声明BSTR的失败尝试。另外,生成(但不要发布)预处理器输出,并验证全局命名空间中是否包含BSTR的定义。