How to convert char * to BSTR?
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