bstr

How to convert char * to BSTR?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 13:13:29
How can I pass a char * from C dll to VB Here is sample code: void Cfunc(char *buffer,int len) { BSTR buf_bstr = SysAllocString((BSTR)buffer); VBptr.VBfunc(buf_bstr,len); } This function is not working, In actual some other values are sent to the VB rather than the actual value. Could anyone please suggest a solution? Call MultiByteToWideChar(), then either SysAllocString() or SysAllocStringLen(). Don't forget to call SysFreeString() when you no longer need the BSTR. In detail (SysAllocStringLen() variant – it's shorter and faster): Call MultiByteToWideChar() and pass 0 as fifth and sixth

How to convert char * to BSTR?

此生再无相见时 提交于 2019-11-26 16:07:24
问题 How can I pass a char * from C dll to VB Here is sample code: void Cfunc(char *buffer,int len) { BSTR buf_bstr = SysAllocString((BSTR)buffer); VBptr.VBfunc(buf_bstr,len); } This function is not working, In actual some other values are sent to the VB rather than the actual value. Could anyone please suggest a solution? 回答1: Call MultiByteToWideChar(), then either SysAllocString() or SysAllocStringLen(). Don't forget to call SysFreeString() when you no longer need the BSTR. In detail