xref: /AOO41X/main/extensions/test/ole/OleConverterVar1/convTest.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_extensions.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #pragma warning (disable: 4917)
32*cdf0e10cSrcweir #include <windows.h>
33*cdf0e10cSrcweir #include <comdef.h>
34*cdf0e10cSrcweir #include <tchar.h>
35*cdf0e10cSrcweir #include <atlbase.h>
36*cdf0e10cSrcweir extern CComModule _Module;
37*cdf0e10cSrcweir #include<atlcom.h>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <stdio.h>
40*cdf0e10cSrcweir #include <com/sun/star/bridge/ModelDependent.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/bridge/XBridgeSupplier2.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <oletest/XTestSequence.hpp>
47*cdf0e10cSrcweir #include <rtl/process.h>
48*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
49*cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
50*cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx>
51*cdf0e10cSrcweir #include <rtl/string.h>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir CComModule _Module;
55*cdf0e10cSrcweir BEGIN_OBJECT_MAP(ObjectMap)
56*cdf0e10cSrcweir END_OBJECT_MAP()
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir #include "smartarray.h"
59*cdf0e10cSrcweir using namespace com::sun::star::bridge;
60*cdf0e10cSrcweir using namespace com::sun::star::bridge::ModelDependent;
61*cdf0e10cSrcweir using namespace com::sun::star::lang;
62*cdf0e10cSrcweir using namespace com::sun::star::uno;
63*cdf0e10cSrcweir using namespace oletest;
64*cdf0e10cSrcweir using namespace cppu;
65*cdf0e10cSrcweir using namespace rtl;
66*cdf0e10cSrcweir HRESULT doTest();
67*cdf0e10cSrcweir HRESULT InitializeParameter();
68*cdf0e10cSrcweir void printResultVariantArray( VARIANT & var);
69*cdf0e10cSrcweir void printVariant( VARIANT & var);
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir int __cdecl _tmain( int argc, _TCHAR * argv[] )
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir 	HRESULT hr;
77*cdf0e10cSrcweir 	if( FAILED( hr=CoInitialize(NULL)))
78*cdf0e10cSrcweir 	{
79*cdf0e10cSrcweir 		_tprintf(_T("CoInitialize failed \n"));
80*cdf0e10cSrcweir 		return -1;
81*cdf0e10cSrcweir 	}
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	_Module.Init( ObjectMap, GetModuleHandle( NULL));
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	if( FAILED(hr=doTest()))
87*cdf0e10cSrcweir 	{
88*cdf0e10cSrcweir 		_com_error err( hr);
89*cdf0e10cSrcweir 		const TCHAR * errMsg= err.ErrorMessage();
90*cdf0e10cSrcweir 		MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
91*cdf0e10cSrcweir 	}
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	_Module.Term();
95*cdf0e10cSrcweir 	CoUninitialize();
96*cdf0e10cSrcweir 	return 0;
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir char _c[]={ 1,2,3,4,5};
99*cdf0e10cSrcweir short _short[]={0xffff, 1, 11 ,111, 1111 };
100*cdf0e10cSrcweir unsigned short _ushort[]={0xffff, 1, 11 ,111, 1111 };
101*cdf0e10cSrcweir long _long[]= { 0xffffffff, 11, 111 ,1111, 1111 };
102*cdf0e10cSrcweir unsigned long _ulong[]= { 0xffffffff, 11, 111 ,1111, 1111 };
103*cdf0e10cSrcweir float _float[]= { 12345.f, 1234.5f, 123.45f, 12.345f, 1.2345f};
104*cdf0e10cSrcweir double _double[]= {12345, 1234.5, 123.45, 12.345, 1.2345};
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir CComVariant _variant[]= {L"variant 1", L"variant2", L"variant3"};
107*cdf0e10cSrcweir wchar_t _wchar[]= {L'1', L'2', L'3', L'A', L' '};
108*cdf0e10cSrcweir BSTR _bstr[]={L"Ich", L"bin", L"ein", L"Hamburger", L"Jung"};
109*cdf0e10cSrcweir SmartArray<char>			arByte( _c, 5, VT_I1);
110*cdf0e10cSrcweir SmartArray< short>			arShort( _short, 5, VT_I2);
111*cdf0e10cSrcweir //SmartArray< unsigned short> arUShort( _ushort, 5, VT_UI2);
112*cdf0e10cSrcweir SmartArray< long>			arLong( _long, 5, VT_I4);
113*cdf0e10cSrcweir //SmartArray< unsigned long>	arULong( _ulong, 5, VT_UI4);
114*cdf0e10cSrcweir //SmartArray< float>			arFloat( _float, 5, VT_R4 );
115*cdf0e10cSrcweir SmartArray< double>			arDouble( _double, 5, VT_R8 );
116*cdf0e10cSrcweir //SmartArray< unsigned short> arWChar( _wchar, 5, VT_UI2 );
117*cdf0e10cSrcweir SmartArray< wchar_t* >		arString( _bstr, 5, VT_BSTR);
118*cdf0e10cSrcweir SmartArray< VARIANT >		 arVariant( _variant, 3, VT_VARIANT);
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir HRESULT doTest()
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir 	HRESULT hr;
124*cdf0e10cSrcweir 	USES_CONVERSION;
125*cdf0e10cSrcweir 	CComPtr<IUnknown> spUnkMgr;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     putenv("UNO_TYPES=types.rdb");
128*cdf0e10cSrcweir     putenv("UNO_SERVICES=services.rdb");
129*cdf0e10cSrcweir     Reference<XComponentContext> xContext = defaultBootstrap_InitialComponentContext();
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	Reference< XMultiComponentFactory > mgr = xContext->getServiceManager();//createRegistryServiceFactory( OUString(L"services.rdb"));
132*cdf0e10cSrcweir 	Reference< XInterface > xIntSupplier= mgr->createInstanceWithContext(
133*cdf0e10cSrcweir         OUString(L"com.sun.star.bridge.OleBridgeSupplierVar1"), xContext);
134*cdf0e10cSrcweir 	Reference< XBridgeSupplier2 > xSuppl( xIntSupplier, UNO_QUERY);
135*cdf0e10cSrcweir 	Reference <XInterface> xOletest= mgr->createInstanceWithContext(
136*cdf0e10cSrcweir         OUString(L"oletest.OleTest"), xContext);
137*cdf0e10cSrcweir 	Any any;
138*cdf0e10cSrcweir 	any <<= xOletest;
139*cdf0e10cSrcweir 	sal_uInt8 arId[16];
140*cdf0e10cSrcweir 	rtl_getGlobalProcessId( arId);
141*cdf0e10cSrcweir 	Any target=	xSuppl->createBridge( any, Sequence<sal_Int8>( (sal_Int8*)arId, 16), UNO, OLE);
142*cdf0e10cSrcweir 	CComDispatchDriver oletest;
143*cdf0e10cSrcweir 	if (target.getValueTypeClass() == getCppuType((sal_uInt32*) 0).getTypeClass())
144*cdf0e10cSrcweir 	{
145*cdf0e10cSrcweir 		VARIANT* pVariant = *(VARIANT**)target.getValue();
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		oletest= pVariant->pdispVal;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 		VariantClear(pVariant);
150*cdf0e10cSrcweir 		CoTaskMemFree(pVariant);
151*cdf0e10cSrcweir 	}
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	CComVariant varRet;
154*cdf0e10cSrcweir 	CComVariant varParam1;
155*cdf0e10cSrcweir 	CComVariant varParam2;
156*cdf0e10cSrcweir 	CComVariant varParam3;
157*cdf0e10cSrcweir 	CComVariant varParam4;
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	long value= 100;
160*cdf0e10cSrcweir 	varParam1.vt= VT_I1 | VT_BYREF;
161*cdf0e10cSrcweir 	varParam1.plVal= &value;
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 	// Testing the caching of DISPIDs and the process of aquiring member information
164*cdf0e10cSrcweir 	// on demand in IDispatch::Invoke
165*cdf0e10cSrcweir 	// Step through the corresponding IDispatch implementation of the ole bridge
166*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varParam1, &varRet);
167*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varParam1, &varRet);
168*cdf0e10cSrcweir 	// Name ok but different case
169*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout_methodByte"), &varParam1, &varRet);
170*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout_methodByte"), &varParam1, &varRet);
171*cdf0e10cSrcweir 	// not existing member
172*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout"), &varParam1, &varRet);
173*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout"), &varParam1, &varRet);
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 	// Property
176*cdf0e10cSrcweir 	varParam1.vt= VT_ARRAY | VT_I1;
177*cdf0e10cSrcweir 	varParam1.parray= (SAFEARRAY*)arByte;
178*cdf0e10cSrcweir 	hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1);
179*cdf0e10cSrcweir 	hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1);
180*cdf0e10cSrcweir 	// Name ok but different case
181*cdf0e10cSrcweir 	hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varParam1);
182*cdf0e10cSrcweir 	hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varParam1);
183*cdf0e10cSrcweir 	// not existing member
184*cdf0e10cSrcweir 	hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attr"), &varParam1);
185*cdf0e10cSrcweir 	hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attr"), &varParam1);
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	// PropertyGet
188*cdf0e10cSrcweir 	hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varRet);
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 	hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varRet);
191*cdf0e10cSrcweir 	hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varRet);
192*cdf0e10cSrcweir 	//not existing member
193*cdf0e10cSrcweir 	hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrBy"), &varRet);
194*cdf0e10cSrcweir 	hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrBy"), &varRet);
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	DISPID dispid;
197*cdf0e10cSrcweir 	LPOLESTR method= L"methodByte";
198*cdf0e10cSrcweir 	hr = oletest.p->GetIDsOfNames(IID_NULL, &method, 1, LOCALE_USER_DEFAULT, &dispid);
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	CComVariant arg[1];
202*cdf0e10cSrcweir 	arg[0].vt= VT_ARRAY | VT_I1;
203*cdf0e10cSrcweir 	arg[0].parray= (SAFEARRAY*)arByte;
204*cdf0e10cSrcweir 	DISPPARAMS params={ arg,0,1,0};
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 	hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
207*cdf0e10cSrcweir 		DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, &varRet, NULL, NULL);
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
210*cdf0e10cSrcweir 		DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, &varRet, NULL, NULL);
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 	// different case
213*cdf0e10cSrcweir 	LPOLESTR method2= L"MEthodByte";
214*cdf0e10cSrcweir 	hr = oletest.p->GetIDsOfNames(IID_NULL, &method2, 1, LOCALE_USER_DEFAULT, &dispid);
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 	hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
217*cdf0e10cSrcweir 		DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, &varRet, NULL, NULL);
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
220*cdf0e10cSrcweir 		DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, &varRet, NULL, NULL);
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 	LPOLESTR attrib= L"AttrByte";
223*cdf0e10cSrcweir 	hr = oletest.p->GetIDsOfNames(IID_NULL, &attrib, 1, LOCALE_USER_DEFAULT, &dispid);
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 	hr = oletest.p->Invoke( dispid, IID_NULL, LOCALE_USER_DEFAULT,
226*cdf0e10cSrcweir 		DISPATCH_METHOD | DISPATCH_PROPERTYPUTREF, &params, &varRet, NULL, NULL);
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	hr = oletest.p->Invoke( dispid, IID_NULL, LOCALE_USER_DEFAULT,
229*cdf0e10cSrcweir 		DISPATCH_METHOD | DISPATCH_PROPERTYGET, &params, &varRet, NULL, NULL);
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	CComVariant varByteArray;
234*cdf0e10cSrcweir 	varByteArray.vt= VT_ARRAY | VT_I1;
235*cdf0e10cSrcweir 	varByteArray.parray= (SAFEARRAY*)arByte;
236*cdf0e10cSrcweir 	CComVariant varShortArray;
237*cdf0e10cSrcweir 	varShortArray.vt= VT_ARRAY | VT_I2;
238*cdf0e10cSrcweir 	varShortArray.parray= (SAFEARRAY*)arShort;
239*cdf0e10cSrcweir 	CComVariant varLongArray;
240*cdf0e10cSrcweir 	varLongArray.vt= VT_ARRAY | VT_I4;
241*cdf0e10cSrcweir 	varLongArray.parray= (SAFEARRAY*)arLong;
242*cdf0e10cSrcweir 	CComVariant varDoubleArray;
243*cdf0e10cSrcweir 	varDoubleArray.vt= VT_ARRAY | VT_R8;
244*cdf0e10cSrcweir 	varDoubleArray.parray= (SAFEARRAY*)arDouble;
245*cdf0e10cSrcweir 	CComVariant varStringArray;
246*cdf0e10cSrcweir 	varStringArray.vt= VT_ARRAY | VT_BSTR;
247*cdf0e10cSrcweir 	varStringArray.parray= (SAFEARRAY*)arString;
248*cdf0e10cSrcweir 	CComVariant varArray;
249*cdf0e10cSrcweir 	varArray.vt= VT_ARRAY | VT_VARIANT;
250*cdf0e10cSrcweir 	varArray.parray= (SAFEARRAY*)arVariant;
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	FONTDESC fd={ sizeof( fd), L"ARIAL", 10, FW_NORMAL, 0, 0, 0, 0};
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 	CComPtr< IUnknown > unk1;
256*cdf0e10cSrcweir 	CComPtr< IUnknown > unk2;
257*cdf0e10cSrcweir 	CComPtr< IUnknown > unk3;
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	IUnknown* _unknown[3];
260*cdf0e10cSrcweir 	hr= OleCreateFontIndirect( &fd, __uuidof( IUnknown), (void**)&unk1.p);
261*cdf0e10cSrcweir 	hr= OleCreateFontIndirect( &fd, __uuidof( IUnknown), (void**)&unk2.p);
262*cdf0e10cSrcweir 	hr= OleCreateFontIndirect( &fd, __uuidof( IUnknown), (void**)&unk3.p);
263*cdf0e10cSrcweir 	_unknown[0]= unk1;
264*cdf0e10cSrcweir 	_unknown[1]= unk2;
265*cdf0e10cSrcweir 	_unknown[2]= unk3;
266*cdf0e10cSrcweir 	SmartArray<IUnknown*> arUnknown( _unknown, 3, VT_UNKNOWN);
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 	CComVariant varUnkArray;
269*cdf0e10cSrcweir 	varUnkArray.vt= VT_ARRAY | VT_UNKNOWN;
270*cdf0e10cSrcweir 	varUnkArray.parray= (SAFEARRAY*)arUnknown;
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 	// preparing out parameter;
273*cdf0e10cSrcweir 	char byteOut;
274*cdf0e10cSrcweir 	CComVariant varOutByte;		//###
275*cdf0e10cSrcweir 	varOutByte.vt= VT_BYREF | VT_UI1;
276*cdf0e10cSrcweir 	V_I1REF(&varOutByte)= &byteOut;
277*cdf0e10cSrcweir 	short shortOut;
278*cdf0e10cSrcweir 	CComVariant varOutShort;	//###
279*cdf0e10cSrcweir 	varOutShort.vt= VT_BYREF | VT_I2;
280*cdf0e10cSrcweir 	V_I2REF( &varOutShort)= &shortOut;
281*cdf0e10cSrcweir 	long longOut;
282*cdf0e10cSrcweir 	CComVariant varOutLong;		//###
283*cdf0e10cSrcweir 	varOutLong.vt= VT_BYREF | VT_I4;
284*cdf0e10cSrcweir 	V_I4REF( &varOutLong)= &longOut;
285*cdf0e10cSrcweir 	double doubleOut;
286*cdf0e10cSrcweir 	CComVariant varOutDouble;	//###
287*cdf0e10cSrcweir 	varOutDouble.vt= VT_BYREF | VT_R8;
288*cdf0e10cSrcweir 	V_R8REF( &varOutDouble)= &doubleOut;
289*cdf0e10cSrcweir 	BSTR bstrOut= NULL;
290*cdf0e10cSrcweir 	CComVariant varOutString;	//###
291*cdf0e10cSrcweir 	varOutString.vt= VT_BYREF | VT_BSTR;
292*cdf0e10cSrcweir 	V_BSTRREF(&varOutString)= &bstrOut;
293*cdf0e10cSrcweir 	CComVariant variantOut;
294*cdf0e10cSrcweir 	CComVariant varOutAny;		//###
295*cdf0e10cSrcweir 	varOutAny.vt= VT_BYREF | VT_VARIANT;
296*cdf0e10cSrcweir 	V_VARIANTREF(&varOutAny)= &variantOut;
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 	CComPtr<IDispatch> dispOut;
299*cdf0e10cSrcweir 	CComVariant varOutXInterface; //###
300*cdf0e10cSrcweir 	varOutXInterface.vt= VT_BYREF |VT_DISPATCH;
301*cdf0e10cSrcweir 	V_DISPATCHREF(&varOutXInterface)= &dispOut.p;
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 	// In Parameter ( all of type Sequence ###########################################################
304*cdf0e10cSrcweir 	OutputDebugString( _T("In parameter of type Sequence ###########################################\n"
305*cdf0e10cSrcweir 		"The functions return the Sequence parameter \n\n"));
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 	OutputDebugStringA("methodByte | Params: \n");
308*cdf0e10cSrcweir 	printVariant( varByteArray);
309*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"methodByte"), &varByteArray, &varRet);
310*cdf0e10cSrcweir 	OutputDebugStringA("methodByte  | return value \n");
311*cdf0e10cSrcweir 	printVariant( varRet);
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 	OutputDebugStringA("methodShort | Params: \n");
314*cdf0e10cSrcweir 	printVariant( varShortArray);
315*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"methodShort"), &varShortArray, &varRet);
316*cdf0e10cSrcweir 	OutputDebugStringA("methodShort  | return value \n");
317*cdf0e10cSrcweir 	printVariant( varRet);
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir 	OutputDebugStringA("methodLong | Params: \n");
320*cdf0e10cSrcweir 	printVariant( varLongArray);
321*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"methodLong"), &varLongArray, &varRet);
322*cdf0e10cSrcweir 	OutputDebugStringA("methodLong  | return value \n");
323*cdf0e10cSrcweir 	printVariant( varRet);
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 	OutputDebugStringA("methodDouble | Params: \n");
326*cdf0e10cSrcweir 	printVariant( varDoubleArray);
327*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"methodDouble"), &varDoubleArray, &varRet);
328*cdf0e10cSrcweir 	OutputDebugStringA("methodDouble  | return value \n");
329*cdf0e10cSrcweir 	printVariant( varRet);
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 	OutputDebugStringA("methodString | Params: \n");
332*cdf0e10cSrcweir 	printVariant( varStringArray);
333*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"methodString"), &varStringArray, &varRet);
334*cdf0e10cSrcweir 	OutputDebugStringA("methodString  | return value \n");
335*cdf0e10cSrcweir 	printVariant( varRet);
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 	OutputDebugStringA("methodAny | Params: \n");
338*cdf0e10cSrcweir 	printVariant( varArray);
339*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"methodAny"), &varArray, &varRet);
340*cdf0e10cSrcweir 	OutputDebugStringA("methodAny  | return value \n");
341*cdf0e10cSrcweir 	printVariant( varRet);
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 	OutputDebugStringA("methodXInterface | Params: \n");
344*cdf0e10cSrcweir 	printVariant( varUnkArray);
345*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"methodXInterface"), &varUnkArray, &varRet);
346*cdf0e10cSrcweir 	OutputDebugStringA("methodAny  | return value \n");
347*cdf0e10cSrcweir 	printVariant( varRet);
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 	// Out Parameter ###########################################################################
350*cdf0e10cSrcweir 	OutputDebugString( _T("Out parameter ###########################################\n\n"));
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodByte  \n"));
353*cdf0e10cSrcweir 	hr=	oletest.InvokeN(static_cast<LPCOLESTR>(L"testout_methodByte"), &varOutByte, 1, &varRet);
354*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodByte  | out value: \n"));
355*cdf0e10cSrcweir 	printVariant( varOutByte);
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodShort \n"));
358*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodShort"), &varOutShort, &varRet);
359*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodShort  | out value: \n"));
360*cdf0e10cSrcweir 	printVariant( varOutShort);
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodLong \n"));
363*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodLong"), &varOutLong, &varRet);
364*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodLong  | out value: \n"));
365*cdf0e10cSrcweir 	printVariant( varOutLong);
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodDouble \n"));
368*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodDouble"), &varOutDouble, &varRet);
369*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodDouble  | out value: \n"));
370*cdf0e10cSrcweir 	printVariant( varOutDouble);
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodString \n"));
373*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodString"), &varOutString, &varRet);
374*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodString  | out value: \n"));
375*cdf0e10cSrcweir 	printVariant( varOutString);
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodAny \n"));
378*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodAny"), &varOutAny, &varRet);
379*cdf0e10cSrcweir 	OutputDebugString(_T("methodAny  | out value: \n"));
380*cdf0e10cSrcweir 	printVariant( varOutAny);
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodXInterface \n"));
383*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodXInterface"), &varOutXInterface, &varRet);
384*cdf0e10cSrcweir 	OutputDebugString(_T("methodAny  | out value: \n"));
385*cdf0e10cSrcweir 	printVariant( varOutXInterface);
386*cdf0e10cSrcweir 	CComDispatchDriver outDisp( *varOutXInterface.ppdispVal);
387*cdf0e10cSrcweir 	CComVariant varAttr3;
388*cdf0e10cSrcweir 	outDisp.GetPropertyByName(L"AttrAny2", &varAttr3);
389*cdf0e10cSrcweir 	ATLTRACE("property OleTest.AttrAny2: %s", W2T(varAttr3.bstrVal));
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodMulParams1 ( 2 out Parameter) \n"));
392*cdf0e10cSrcweir 	long longOut2=0;
393*cdf0e10cSrcweir 	CComVariant _params[2];
394*cdf0e10cSrcweir 	longOut=0;
395*cdf0e10cSrcweir 	_params[0]= varOutLong;
396*cdf0e10cSrcweir 	_params[1].vt= VT_BYREF | VT_I4;
397*cdf0e10cSrcweir 	V_I4REF(& _params[1])= &longOut2;
398*cdf0e10cSrcweir 	hr=	oletest.InvokeN( static_cast<LPCOLESTR>(L"testout_methodMulParams1"), (VARIANT*)&_params, 2);
399*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodMulParams1  | out values: \n"));
400*cdf0e10cSrcweir 	printVariant( _params[1]);
401*cdf0e10cSrcweir 	printVariant( _params[0]);
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodMulParams2 ( 3 out Parameter) \n"));
404*cdf0e10cSrcweir 	CComVariant _params2[3];
405*cdf0e10cSrcweir 	_params2[2]= varOutLong;
406*cdf0e10cSrcweir 	_params2[1].vt= VT_BYREF | VT_I4;
407*cdf0e10cSrcweir 	V_I4REF(& _params2[1])= &longOut2;
408*cdf0e10cSrcweir 	_params2[0]= varOutString;
409*cdf0e10cSrcweir 	hr=	oletest.InvokeN( static_cast<LPCOLESTR>( L"testout_methodMulParams2"), (VARIANT*)&_params2, 3);
410*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodMulParams2  | out values: \n"));
411*cdf0e10cSrcweir 	printVariant( _params2[2]);
412*cdf0e10cSrcweir 	printVariant( _params2[1]);
413*cdf0e10cSrcweir 	printVariant( _params2[0]);
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodMulParams3 ( 1 in and 1 out Parameter) \n"));
416*cdf0e10cSrcweir 	CComVariant _params3[2];
417*cdf0e10cSrcweir 	_params3[1]= CComBSTR(L" In string");
418*cdf0e10cSrcweir 	_params3[0]= varOutString;
419*cdf0e10cSrcweir 	hr=	oletest.InvokeN( static_cast<LPCOLESTR>( L"testout_methodMulParams3"), (VARIANT*)&_params3, 2);
420*cdf0e10cSrcweir 	OutputDebugString(_T("testout_methodMulParams3  | out values: \n"));
421*cdf0e10cSrcweir 	printVariant( _params3[1]);
422*cdf0e10cSrcweir 	printVariant( _params3[0]);
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 	//In Out Parameter ###########################################################################
425*cdf0e10cSrcweir 	OutputDebugString( _T("In Out parameter ###########################################\n\n"));
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 	*V_I1REF(&varOutByte)= 5;
428*cdf0e10cSrcweir 	ATLTRACE(_T("testinout_methodByte | in value: %d \n"), *V_I1REF(&varOutByte));
429*cdf0e10cSrcweir 	hr=	oletest.InvokeN(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varOutByte, 1, &varRet);
430*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodByte  | out value: \n"));
431*cdf0e10cSrcweir 	printVariant( varOutByte);
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodShort | in value= 1000 \n"));
434*cdf0e10cSrcweir 	*V_UI2REF(&varOutShort)= 1000;
435*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodShort"), &varOutShort, &varRet);
436*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodShort  | out value: \n"));
437*cdf0e10cSrcweir 	printVariant( varOutShort);
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodLong | in value= 10000 \n"));
440*cdf0e10cSrcweir 	*V_UI4REF(&varOutLong)= 10000;
441*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodLong"), &varOutLong, &varRet);
442*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodLong  | out value: \n"));
443*cdf0e10cSrcweir 	printVariant( varOutLong);
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 	*V_R8REF(&varOutDouble)= 3.14;
446*cdf0e10cSrcweir 	ATLTRACE(_T("testinou_methodDouble in value: %f \n"),*V_R8REF(&varOutDouble));
447*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodDouble"), &varOutDouble, &varRet);
448*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodDouble  | out value: \n"));
449*cdf0e10cSrcweir 	printVariant( varOutDouble);
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir 	SysFreeString( *V_BSTRREF(&varOutString));
452*cdf0e10cSrcweir 	*V_BSTRREF(&varOutString)= SysAllocString( L"this is a in string");
453*cdf0e10cSrcweir 	ATLTRACE(_T("testinout_methodString | value: %s \n"), W2T(*V_BSTRREF(&varOutString)));
454*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodString"), &varOutString, &varRet);
455*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodString  | out value: \n"));
456*cdf0e10cSrcweir 	printVariant( varOutString);
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir 	CComVariant var1(CComBSTR(L" this is a string in a VARIANT"));
459*cdf0e10cSrcweir 	CComVariant outVar1;
460*cdf0e10cSrcweir 	outVar1.vt= VT_BYREF | VT_VARIANT;
461*cdf0e10cSrcweir 	outVar1.pvarVal= &var1;
462*cdf0e10cSrcweir 	ATLTRACE(_T("testinout_methodAny | parameter: %s\n"), W2T(var1.bstrVal));
463*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodAny"), &varOutAny, &varRet);
464*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodAny  | out value: \n"));
465*cdf0e10cSrcweir 	printVariant( varOutAny);
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir 	CComPtr< IUnknown > objectIn = unk1;
468*cdf0e10cSrcweir 	CComVariant varOutIFace;
469*cdf0e10cSrcweir 	varOutIFace.vt= VT_BYREF | VT_UNKNOWN;
470*cdf0e10cSrcweir 	varOutIFace.ppunkVal= &objectIn.p;
471*cdf0e10cSrcweir 	(*varOutIFace.ppunkVal)->AddRef();
472*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodXInterface | in value: \n"));
473*cdf0e10cSrcweir 	printVariant(varOutIFace);
474*cdf0e10cSrcweir 	hr=	oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodXInterface"), &varOutIFace, &varRet);
475*cdf0e10cSrcweir 	OutputDebugString(_T("testinout_methodXInterface  | out value: \n"));
476*cdf0e10cSrcweir 	printVariant( varOutIFace);
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir 	// Properties ######################################################################
479*cdf0e10cSrcweir 	OutputDebugString( _T(" Properties ###########################################\n\n"));
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir 	OutputDebugString(_T("set property \"AttrByte\" | value"));
482*cdf0e10cSrcweir 	//CComVariant propArByte;
483*cdf0e10cSrcweir 	//propArByte.vt= VT_ARRAY | VT_I1;
484*cdf0e10cSrcweir   	varParam1.parray= (SAFEARRAY*)arByte;
485*cdf0e10cSrcweir 	printVariant( varParam1);
486*cdf0e10cSrcweir 	hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1);
487*cdf0e10cSrcweir 	OutputDebugString(_T("get property \"AttrByte\" | value:"));
488*cdf0e10cSrcweir 	varRet.Clear();
489*cdf0e10cSrcweir 	hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varRet);
490*cdf0e10cSrcweir 	printVariant( varRet);
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 	return S_OK;
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir }
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir void printVariant( VARIANT & _var)
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir 	HRESULT hr;
502*cdf0e10cSrcweir 	USES_CONVERSION;
503*cdf0e10cSrcweir 	CComVariant var;
504*cdf0e10cSrcweir 	hr=	VariantCopyInd( &var, &_var);
505*cdf0e10cSrcweir 	if( var.vt & VT_ARRAY)
506*cdf0e10cSrcweir 	{
507*cdf0e10cSrcweir 		VARTYPE type= var.vt ^ VT_ARRAY;
508*cdf0e10cSrcweir 		SAFEARRAY * sarray= var.parray;
509*cdf0e10cSrcweir 		long lbound;
510*cdf0e10cSrcweir 		long ubound;
511*cdf0e10cSrcweir 		hr= SafeArrayGetLBound( sarray, 1, &lbound);
512*cdf0e10cSrcweir 		hr= SafeArrayGetUBound( sarray, 1, &ubound);
513*cdf0e10cSrcweir 		long count= ubound - lbound + 1;
514*cdf0e10cSrcweir 		char charValue;
515*cdf0e10cSrcweir 		BYTE byteValue;
516*cdf0e10cSrcweir 		short shortValue;
517*cdf0e10cSrcweir 		long longValue;
518*cdf0e10cSrcweir 		double doubleValue;
519*cdf0e10cSrcweir 		IUnknown* unkValue;
520*cdf0e10cSrcweir 		BSTR bstrValue;
521*cdf0e10cSrcweir 		OutputDebugString( _T("# Array \n"));
522*cdf0e10cSrcweir 		for( long i= 0; i < count; i++)
523*cdf0e10cSrcweir 		{
524*cdf0e10cSrcweir //			CComVariant variantValue;
525*cdf0e10cSrcweir 			TCHAR *buf[256];
526*cdf0e10cSrcweir 			wsprintf( (TCHAR*)buf, _T("%d : "), i);
527*cdf0e10cSrcweir 			OutputDebugString( (TCHAR*)buf);
528*cdf0e10cSrcweir 			VARIANT varTemp;
529*cdf0e10cSrcweir 			VariantInit( &varTemp);
530*cdf0e10cSrcweir 			VARIANT variantValue;
531*cdf0e10cSrcweir 			VariantInit( &variantValue);
532*cdf0e10cSrcweir 			switch( type)
533*cdf0e10cSrcweir 			{
534*cdf0e10cSrcweir 			case VT_UI1:
535*cdf0e10cSrcweir 				hr= SafeArrayGetElement( sarray, &i, &byteValue);
536*cdf0e10cSrcweir 				varTemp.vt= VT_UI1;
537*cdf0e10cSrcweir 				V_UI1( &varTemp)= byteValue;
538*cdf0e10cSrcweir 				printVariant( varTemp);
539*cdf0e10cSrcweir 				break;
540*cdf0e10cSrcweir 			case VT_I1:
541*cdf0e10cSrcweir 				hr= SafeArrayGetElement( sarray, &i, &charValue);
542*cdf0e10cSrcweir 				varTemp.vt= VT_I1;
543*cdf0e10cSrcweir 				V_I1( &varTemp)= charValue;
544*cdf0e10cSrcweir 				printVariant( varTemp);
545*cdf0e10cSrcweir 				break;
546*cdf0e10cSrcweir 			case VT_I2:
547*cdf0e10cSrcweir 				hr= SafeArrayGetElement( sarray, &i, &shortValue);
548*cdf0e10cSrcweir 				varTemp.vt= VT_I2;
549*cdf0e10cSrcweir 				V_I2( &varTemp)= shortValue;
550*cdf0e10cSrcweir 				printVariant( varTemp);
551*cdf0e10cSrcweir 				break;
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir 			case VT_UI2:
554*cdf0e10cSrcweir 			case VT_I4:
555*cdf0e10cSrcweir 				hr= SafeArrayGetElement( sarray, &i, &longValue);
556*cdf0e10cSrcweir 				varTemp.vt= VT_I4;
557*cdf0e10cSrcweir 				V_I4( &varTemp)= longValue;
558*cdf0e10cSrcweir 				printVariant( varTemp);
559*cdf0e10cSrcweir 				break;
560*cdf0e10cSrcweir 			case VT_R8:
561*cdf0e10cSrcweir 				hr= SafeArrayGetElement( sarray, &i, &doubleValue);
562*cdf0e10cSrcweir 				varTemp.vt= VT_R8;
563*cdf0e10cSrcweir 				V_R8( &varTemp)= doubleValue;
564*cdf0e10cSrcweir 				printVariant( varTemp);
565*cdf0e10cSrcweir 				break;
566*cdf0e10cSrcweir 			case VT_BSTR:
567*cdf0e10cSrcweir 				hr= SafeArrayGetElement( sarray, &i, &bstrValue);
568*cdf0e10cSrcweir 				varTemp.vt= VT_BSTR;
569*cdf0e10cSrcweir 				varTemp.bstrVal= bstrValue;
570*cdf0e10cSrcweir 				printVariant( varTemp);
571*cdf0e10cSrcweir 				break;
572*cdf0e10cSrcweir 			case VT_VARIANT:
573*cdf0e10cSrcweir 				hr= SafeArrayGetElement( sarray, &i, &varTemp);
574*cdf0e10cSrcweir 				printVariant( varTemp);
575*cdf0e10cSrcweir 				break;
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir 			case VT_UNKNOWN:
578*cdf0e10cSrcweir 				hr= SafeArrayGetElement( sarray, &i, &unkValue);
579*cdf0e10cSrcweir 				varTemp.vt= VT_UNKNOWN;
580*cdf0e10cSrcweir 				varTemp.punkVal= unkValue;
581*cdf0e10cSrcweir 				printVariant( varTemp);
582*cdf0e10cSrcweir 				break;
583*cdf0e10cSrcweir 			}
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 			VariantClear( &varTemp);
586*cdf0e10cSrcweir 			VariantClear( &variantValue);
587*cdf0e10cSrcweir 		}
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir 	}
590*cdf0e10cSrcweir 	else
591*cdf0e10cSrcweir 	{
592*cdf0e10cSrcweir 		TCHAR buf[256];
593*cdf0e10cSrcweir 		switch (var.vt)
594*cdf0e10cSrcweir 		{
595*cdf0e10cSrcweir 		case VT_I1: wsprintf( (TCHAR*)buf, _T(" VT_I1: %d \n"), V_I1( &var) );
596*cdf0e10cSrcweir 			break;
597*cdf0e10cSrcweir 		case VT_UI1: wsprintf( (TCHAR*)buf, _T(" VT_UI1: %d \n"), V_I1( &var) );
598*cdf0e10cSrcweir 			break;
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir 		case VT_I2: wsprintf( (TCHAR*)buf, _T(" VT_I2: %d \n"), V_I2( &var) );
601*cdf0e10cSrcweir 			break;
602*cdf0e10cSrcweir 		case VT_I4: wsprintf( (TCHAR*)buf, _T(" VT_I4: %d \n"), V_I4( &var) );
603*cdf0e10cSrcweir 			break;
604*cdf0e10cSrcweir 		case VT_R8:
605*cdf0e10cSrcweir 			{
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir //				int     decimal,   sign;
608*cdf0e10cSrcweir //				char    *buffer;
609*cdf0e10cSrcweir //				int     precision = 14;
610*cdf0e10cSrcweir //				double  source = 3.1415926535;
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir //				buffer = _ecvt( V_R8(&var), precision, &decimal, &sign );
613*cdf0e10cSrcweir 				sprintf( (TCHAR*)buf, _T(" VT_R8: %f \n"),V_R8( &var) );
614*cdf0e10cSrcweir 			break;
615*cdf0e10cSrcweir 			}
616*cdf0e10cSrcweir 		case VT_UNKNOWN:
617*cdf0e10cSrcweir 			// The object implement IFont
618*cdf0e10cSrcweir 			{
619*cdf0e10cSrcweir 				CComDispatchDriver disp( var.punkVal);
620*cdf0e10cSrcweir 				CComVariant ret;
621*cdf0e10cSrcweir 				hr= disp.GetPropertyByName( static_cast<LPCOLESTR>(L"Name"), &ret);
622*cdf0e10cSrcweir 				wsprintf( (TCHAR*)buf, _T(" VT_UNKNOWN: property \"Name\": %s \n"), W2T(ret.bstrVal));
623*cdf0e10cSrcweir 				break;
624*cdf0e10cSrcweir 			}
625*cdf0e10cSrcweir 		case VT_DISPATCH:
626*cdf0e10cSrcweir 			// The object implement IFont
627*cdf0e10cSrcweir 			{
628*cdf0e10cSrcweir 				CComDispatchDriver disp( var.punkVal);
629*cdf0e10cSrcweir 				CComVariant ret;
630*cdf0e10cSrcweir 				if( SUCCEEDED( hr= disp.GetPropertyByName( static_cast<LPCOLESTR>(L"Name"), &ret)))
631*cdf0e10cSrcweir 					wsprintf( (TCHAR*)buf, _T(" VT_DISPATCH: property \"Name\": %s \n"), W2T(ret.bstrVal));
632*cdf0e10cSrcweir 				else
633*cdf0e10cSrcweir 					wsprintf( (TCHAR*)buf, _T(" VT_DISPATCH \n"));
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir 				break;
636*cdf0e10cSrcweir 			}
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir 		case VT_BSTR:
640*cdf0e10cSrcweir 			{
641*cdf0e10cSrcweir 				TCHAR* str= W2T( var.bstrVal);
642*cdf0e10cSrcweir 				wsprintf( (TCHAR*)buf, _T(" VT_BSTR: %s \n"), str);
643*cdf0e10cSrcweir 			}
644*cdf0e10cSrcweir 			break;
645*cdf0e10cSrcweir 		default:
646*cdf0e10cSrcweir 			wsprintf( (TCHAR*)buf, _T("\n"));
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir 		}
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir 		OutputDebugString( (TCHAR*) buf);
651*cdf0e10cSrcweir 	}
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir 		return;
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir }
656*cdf0e10cSrcweir 
657