Hello , i'd like to know how to convert a char* into a VARIANT and vice-versa. I have an VB interface that will pass me a variant and inside my c++ code i'll use it as VARIANT
with VB you can change unicode strings. In them a character instead of one byte have two bytes. The type in wchar_t or BSTR instead of char.
for example
char* x="hello";
wchar_t*y=L"hello";//pay attention on L"
BSTR* z=L"hello";
in COMAPI you'll work as:
VARIANT x;
VariantInit(&x);
V_VT(&x)=VT_BSTR;
V_BSTR(&x)=SysAllocString(L"hello"
....using x
VariantClear(x);
It atl is much simplier:
_variant_t x;
x=L"hello";
for using ATL is enough to
#include<atlbase.h>
#include<comdef.h> John Fill
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.