将char *转换为包含特殊字符的BSTR *

| 我正在尝试将ѭ0转换为ѭ1,而我的ѭ0却具有特殊字符,无法进行加密。我尝试了在Web上找到的几种方法,但是回到调用vb代码的过程中,我总是得到不同的结果。我很确定这与特殊字符有关,因为如果我没有特殊字符,那似乎还可以。 我的代码就是这样的东西...
_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);
任何帮助将不胜感激! 谢谢!!!!     
已邀请:
如果要操纵缓冲区,则可能不想直接操纵
char *
。首先进行复制:
_export myFunction(BSTR *VBtextin, BSTR *VBpassword, BSTR *VBtextout, FPINT encrypt) {

  UINT length = SysStringLen(*VBpassword) + 1;
  char* my_char = new char[length];
  HRESULT hr = StringCchCopy(my_char, length, *VBpassword);
如果一切成功,请执行转换。确保适当地处理故障。
  if (SUCCEEDED(hr)) {
    // Perform transformations...
  }
然后复制回来:
  *VBtextout = SysAllocString(my_char);
  delete [] my_char;
}
另外,请阅读Eric的BSTR语义完整指南。     

要回复问题请先登录注册