将char *转换为包含特殊字符的BSTR * [英] converting a char* to BSTR* which contains special characters…

查看:107
本文介绍了将char *转换为包含特殊字符的BSTR *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在尝试将char *转换为BSTR *,并且char *中的特殊字符不被加密.我尝试了在网络上找到的几种方法,但是回到调用vb代码的过程中,我总是得到不同的结果.我很确定这与特殊字符有关,因为如果我不输入特殊字符,这似乎还可以....

我的代码符合这些原则...

Hello,

I''m trying to convert a char* to a BSTR*, and my char* has special characters in it from being encrypted. I have tried several approaches found on the web, but back in the calling vb code, I always end up with something different. I''m pretty sure this has to do with the special characters, because if I don''t have them in, it seems to be ok....

my code is something along these lines...

_export myFunction(BSTR *VBtextin, BSTR *VBpassword, BSTR *VBtextout, FPINT encrypt) {

BSTR password = SysAllocString (*VBpassword);
char* myChar;
myChar = (char*) password  //is this ok to cast? it seems to remain the same when i print out.

//then I encrypt the myChar in some function...and want to convert back to BSTR
//i''ve tried a few ways like below, and some other ways i''ve seen online...to no avail.

_bstr_t temp(myChar);
SysReAllocString(VBtextout, myChar);



任何帮助将非常非常感谢!!!
谢谢.



Any help would be very very very much appreciated!!!
Thanks.

推荐答案

不,您不能将BSTR 强制转换为char*.使用ConvertBSTRToString.

请参阅 http://msdn.microsoft.com/en-us/library/ewezf1f6(v = VS.100).aspx [
No, you cannot cast a BSTR to a char*. Use ConvertBSTRToString.

See http://msdn.microsoft.com/en-us/library/ewezf1f6(v=VS.100).aspx[^]


这篇关于将char *转换为包含特殊字符的BSTR *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆