错,ConvertStringToBSTR在转化二进制数据会出问题 而且,你根本就不需要char to BSTR 直接 SysAllocStringByteLen(NULL,you_len); CopyMemory(s_flag,cc,you_len); 注意看msdn的对第一个参数为空的解释 If psz is Null, a string of the requested length is allocated, but not initialized. The string psz can contain embedded null characters, and does not need to end with a Null. Free the returned string later with SysFreeString.
而且,你根本就不需要char to BSTR
直接
SysAllocStringByteLen(NULL,you_len);
CopyMemory(s_flag,cc,you_len);
注意看msdn的对第一个参数为空的解释
If psz is Null, a string of the requested length is allocated, but not initialized. The string psz can contain embedded null characters, and does not need to end with a Null. Free the returned string later with SysFreeString.
这种方法在dll中有用,应为地址都在同一内存空间中
要是进程间呢,或者不同机器间呢,搞个屁啊