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