_variant_t to CStringArray
-
Hi All i have
_variant_t data
type variable,which have contain 10 values.Like this
[0,0] = BSTR = 0x0017a66c "Name"
[0,1] = BSTR = 0x0017a6ec "Age"
[0,2] = BSTR = 0x0017a6ec "Class"
...data is a SAFEARRAY containing BSTR elements.so how can i convert _variant_ to CStringArray? Plz help me
-
Hi All i have
_variant_t data
type variable,which have contain 10 values.Like this
[0,0] = BSTR = 0x0017a66c "Name"
[0,1] = BSTR = 0x0017a6ec "Age"
[0,2] = BSTR = 0x0017a6ec "Class"
...data is a SAFEARRAY containing BSTR elements.so how can i convert _variant_ to CStringArray? Plz help me
See for instance [^]. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi All i have
_variant_t data
type variable,which have contain 10 values.Like this
[0,0] = BSTR = 0x0017a66c "Name"
[0,1] = BSTR = 0x0017a6ec "Age"
[0,2] = BSTR = 0x0017a6ec "Class"
...data is a SAFEARRAY containing BSTR elements.so how can i convert _variant_ to CStringArray? Plz help me
-
thanks for reply but it's not helpfull for my problem.So plz help me
-
thanks for reply but it's not helpfull for my problem.So plz help me
Those links are actually helpful, because they give you C++ wrappers for SAFEARRAYs that will simplify the job of converting the SAFEARRAY to some other array of strings.
CComSafeArray<BSTR> safearrayOfBstr(((VARIANT)data).parray);
will wrap the SAFEARRAY contained in the VARIANT. You can then use the CComSafeArray methods to access the SAFEARRAY data. This article[^] is very useful, because it gives easier access to 2D SAFEARRAYs, which is what you've got here. Thing is, it's up to you to do that final step of converting to your CStringArray - but all you need to do is iterate through the relevant elements of the SAFEARRAY, extract the BSTR, convert it to a CString and store that in your CStringArray - not tricky, really!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p