COleVariant problem with strings
Fadel Al-Jaifi -- hamd@ritsec3.com.eg Tuesday, June 25, 1996 vc++ 4.0 /win95 Hello there I have a problem with COleVariant , I created an object of type COleVariant and passed a CString object as a parameter to the constructor ,then when I used V_BSTRT to retrieve the string ,I only got the first character. here is the code: COleVariant var(CString(_T("any text"))); AfxMessageBox(V_BSTRT(&var)); then I only got the first character displayed in the message box! I hope somebody can help.. thanks fadel
Rohit Namjoshi -- namjoshi@slb.com Thursday, June 27, 1996 [Mini-digest: 3 responses] Unicode strikes again! Try: COleVariant var(CString(_T("any text")), VT_BSTRT); Cheers... Rohit -- Rohit Namjoshi namjoshi@austin.asc.slb.com Schlumberger Austin Product Center Vox: +1 512 331 3353 Austin, TX 78726, USA Fax: +1 512 331 3320 -----From: CraigTT@ccmail01.PE-Nelson.COM Fadel, I'm assuming that you're compiling ANSI rather than UNICODE since you're using Win95. BSTR's are always UNICODE. The COleVariant constructor takes your ANSI string and converts it to UNICODE for you. When you pass this to AfxMessageBox, it tries to interpret this as ANSI and sees the second half of the first UNICODE character as a NULL character and thinks it's done displaying the text. Tim Craig PE-Nelson -----From: "Julius Hamelberg"Try this function: HRESULT VariantChangeType(pvargDest, pvargSrc, wFlags, vtNew)
| Вернуться в корень Архива |