VARIANT to CString
-
Hi how can i chane VARIANT to CString?
VARIANT var=pRange->GetValue();
CString strp;
str=CString(var.bstrVal);some time i got exception
Unhandled exception at 0x7c80a30a in test.exe: 0xC0000005: Access violation reading location 0x001e2000.
Call stack show
test.exe!ATL::ChTraitsCRT<char>::GetBaseTypeLength(const wchar_t * pszSource=0x001e1f98) Line 284 + 0x1e bytes C++
in cstring.h class pointing
static int __cdecl GetBaseTypeLength( _In_z_ LPCWSTR pszSource ) throw()
{
// Returns required buffer length in XCHARs
return ::WideCharToMultiByte( _AtlGetConversionACP(), 0, pszSource, -1, NULL, 0, NULL, NULL )-1;
}Can any one tell me region behind of exception. Plz help me
-
Hi how can i chane VARIANT to CString?
VARIANT var=pRange->GetValue();
CString strp;
str=CString(var.bstrVal);some time i got exception
Unhandled exception at 0x7c80a30a in test.exe: 0xC0000005: Access violation reading location 0x001e2000.
Call stack show
test.exe!ATL::ChTraitsCRT<char>::GetBaseTypeLength(const wchar_t * pszSource=0x001e1f98) Line 284 + 0x1e bytes C++
in cstring.h class pointing
static int __cdecl GetBaseTypeLength( _In_z_ LPCWSTR pszSource ) throw()
{
// Returns required buffer length in XCHARs
return ::WideCharToMultiByte( _AtlGetConversionACP(), 0, pszSource, -1, NULL, 0, NULL, NULL )-1;
}Can any one tell me region behind of exception. Plz help me
Maybe your VARIANT doesn't contain a string but something else?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
Maybe your VARIANT doesn't contain a string but something else?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
Well, as i said, it could be that your VARIANT contains something else than a string, like an integer for example, check this[^] out and you will see there can be a lot of datatypes a VARIANT can hold. So -based on what you see there- you should either skip non-string values or maybe convert what you can to a string if you really need to work with a string.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
Use VariantChangeType[^] to convert the VARIANT to one holding a BSTR representation of the data before trying to use the BSTR.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p