【发布时间】:2011-08-09 19:54:25
【问题描述】:
我正在尝试将char* 转换为BSTR*,而我的char* 中包含特殊字符以防被加密。我尝试了几种在网上找到的方法,但在调用 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);
任何帮助将不胜感激!!!
谢谢!!!!
【问题讨论】:
-
你到底想做什么?您是否正在尝试将 VB 与 C 代码接口?
-
是的...完全正确....VB 代码正在调用 C 代码...然后回到 VB 代码。
-
你找到解决这个问题的方法了吗?