Save a VARIANT type  into an XML file without COleVariant

marti23esp
marti23esp used Ask the Experts™
on
The variant type could be an array of longs or unsigned longs...

I can use ...
comdef.h
or...
Oleauto.h

but I can´t use...
//#include "StdAfx.h"
//#include "afxdisp.h"

due to problems with multithreaded libraries look in...
http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20397230.html

any idea. I think that question is really difficult but I don´t have more points.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I solved it.

_bstr_t test=     (_bstr_t)vArg2;

vArg2 = (_variant_t) test;
                   
hr =VariantChangeType(&vArg2,&vArg2 ,VARIANT_NOVALUEPROP,( VT_ARRAY | VT_UI1 ));
                             

Author

Commented:
It wasn´t that easy it was needed to use wchar with just char it didn´t works.

                    for( int iFeature=0;iFeature<FEATURES_NUM;iFeature++){
                         VARIANT vArg2;
                         VariantInit( &vArg2 );
                         double poSimilarity1 = 1.0;
                         if( SUCCEEDED( (m_pIFeature[iFeature])->Descriptor( &vArg2 ))) {

                         _bstr_t test=     (_bstr_t)vArg2;
                         /*char*  test2=test.operator char *();
                         _bstr_t test3=(_bstr_t)test2;*/

                         wchar_t *test2=new wchar_t[_bstr_t(test).length()];
                         wcscpy(test2,(wchar_t*)test);
                         
                         _bstr_t test3=_bstr_t(test2);

                         vArg2 = (_variant_t) test3;
                   
try{
                         hr =VariantChangeType(&vArg2,&vArg2 ,VARIANT_NOVALUEPROP,( VT_ARRAY | VT_UI1 ));
                              if (FAILED(hr)) _com_issue_error(hr);          
                         
                              hr=(m_pIFeature[iFeature])->Similarity(vArg2,&poSimilarity1);
                              if (FAILED(hr)) _com_issue_error(hr);


               
         
}catch(_com_error& err){
         
     cout<<err.ErrorMessage()<<endl;
}
Commented:
PAQ'd and points refunded to save your solution in the knowledgebase.

modulo

Community Support Moderator
Experts Exchange

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial