1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #include "stdafx.h"
24 //#include "AxTestComponents.h"
25 #include "Basic.h"
26 
27 
28 
29 /////////////////////////////////////////////////////////////////////////////
30 // CBasic
CBasic()31 CBasic::CBasic():	m_cPrpByte(0),m_nPrpShort(0),m_lPrpLong(0),m_fPrpFloat(0), m_dPrpDouble(0),m_PrpArray(0),
32 m_safearray(NULL), m_bool(VARIANT_FALSE),
33 m_arByte(0), m_arShort(0), m_arLong(0), m_arString(0), m_arVariant(0), m_arFloat(0),
34 m_arDouble(0), m_arObject(0), m_arByteDim2(0), m_date(0.), m_scode(0)
35 
36 {
37 	memset(&m_cy, 0, sizeof(CY));
38 	memset(&m_decimal, 0, sizeof(DECIMAL));
39 }
40 
~CBasic()41 CBasic::~CBasic()
42 {
43 	SafeArrayDestroy(m_safearray);
44 	SafeArrayDestroy(m_arByte);
45 	SafeArrayDestroy(m_arShort);
46 	SafeArrayDestroy(m_arLong);
47 	SafeArrayDestroy(m_arString);
48 	SafeArrayDestroy(m_arVariant);
49 	SafeArrayDestroy(m_arFloat);
50 	SafeArrayDestroy(m_arDouble);
51 	SafeArrayDestroy(m_arObject);
52 	SafeArrayDestroy(m_arByteDim2);
53 
54 }
inBool(VARIANT_BOOL val)55 STDMETHODIMP CBasic::inBool(VARIANT_BOOL val)
56 {
57 	m_bool = val;
58 	return S_OK;
59 }
inByte(unsigned char val)60 STDMETHODIMP CBasic::inByte(unsigned char val)
61 {
62 	m_byte = val;
63 	return S_OK;
64 }
65 
inShort(short val)66 STDMETHODIMP CBasic::inShort(short val)
67 {
68 	m_short = val;
69 	return S_OK;
70 }
71 
inLong(long val)72 STDMETHODIMP CBasic::inLong(long val)
73 {
74 	m_long = val;
75 	return S_OK;
76 }
77 
inString(BSTR val)78 STDMETHODIMP CBasic::inString(BSTR val)
79 {
80 	m_bstr = val;
81 	return S_OK;
82 }
83 
inFloat(float val)84 STDMETHODIMP CBasic::inFloat(float val)
85 {
86 	m_float = val;
87 	return S_OK;
88 }
89 
inDouble(double val)90 STDMETHODIMP CBasic::inDouble(double val)
91 {
92 	m_double = val;
93 
94 	CComVariant varDest;
95 	CComVariant varSource(val);
96 	HRESULT hr = VariantChangeType(&varDest, &varSource, 0, VT_BSTR);
97 	return S_OK;
98 }
99 
inVariant(VARIANT val)100 STDMETHODIMP CBasic::inVariant(VARIANT val)
101 {
102 	m_var1 = val;
103 	return S_OK;
104 }
105 
inArray(LPSAFEARRAY val)106 STDMETHODIMP CBasic::inArray(LPSAFEARRAY val)
107 {
108 	HRESULT hr = S_OK;
109 	if (FAILED(hr = SafeArrayDestroy(m_safearray)))
110 		return hr;
111 	if (FAILED(hr = SafeArrayCopy(val, &m_safearray)))
112 		return hr;
113 	return S_OK;
114 }
115 
inObject(IDispatch * val)116 STDMETHODIMP CBasic::inObject(IDispatch *val)
117 {
118 	m_obj = val;
119 	return S_OK;
120 }
121 
inoutBool(VARIANT_BOOL * val)122 STDMETHODIMP CBasic::inoutBool(VARIANT_BOOL* val)
123 {
124 	VARIANT_BOOL aBool = *val;
125 	*val = m_bool;
126 	m_bool = aBool;
127 	return S_OK;
128 }
129 
130 
inoutByte(unsigned char * val)131 STDMETHODIMP CBasic::inoutByte(unsigned char* val)
132 {
133 	unsigned char aByte = *val;
134 	*val = m_byte;
135 	m_byte = aByte;
136 	return S_OK;
137 }
138 
inoutShort(short * val)139 STDMETHODIMP CBasic::inoutShort(short *val)
140 {
141 	short aShort = *val;
142 	*val = m_short;
143 	m_short = aShort;
144 	return S_OK;
145 }
146 
inoutLong(long * val)147 STDMETHODIMP CBasic::inoutLong(long *val)
148 {
149 	long aLong = *val;
150 	*val = m_long;
151 	m_long = aLong;
152 	return S_OK;
153 }
154 
inoutString(BSTR * val)155 STDMETHODIMP CBasic::inoutString(BSTR *val)
156 {
157 	CComBSTR aStr = *val;
158 	HRESULT hr = S_OK;
159 	if (FAILED( hr = m_bstr.CopyTo(val)))
160 		return hr;
161 	m_bstr = aStr;
162 	return S_OK;
163 }
164 
inoutFloat(float * val)165 STDMETHODIMP CBasic::inoutFloat(float *val)
166 {
167 	float aFloat = *val;
168 	*val = m_float;
169 	m_float = aFloat;
170 	return S_OK;
171 }
172 
inoutDouble(double * val)173 STDMETHODIMP CBasic::inoutDouble(double *val)
174 {
175 	double aDouble = *val;
176 	*val = m_double;
177 	m_double  = aDouble;
178 	return S_OK;
179 }
180 
inoutVariant(VARIANT * val)181 STDMETHODIMP CBasic::inoutVariant(VARIANT *val)
182 {
183 	CComVariant aVar = *val;
184 	HRESULT hr = S_OK;
185 	if (FAILED(hr = VariantCopy(val, &m_var1)))
186 		return hr;
187 	m_var1 = aVar;
188 	return S_OK;
189 }
190 
191 /* The array contains VARIANT according to IDL.
192 	If the VARIANTs contain strings then we append "out" to each string.
193 */
inoutArray(LPSAFEARRAY * val)194 STDMETHODIMP CBasic::inoutArray(LPSAFEARRAY *val)
195 {
196 	SAFEARRAY* aAr = NULL;
197 	HRESULT hr = S_OK;
198 	if (FAILED(hr = SafeArrayCopy(*val, &aAr)))
199 		return hr;
200 	if (FAILED(hr = SafeArrayCopy(m_safearray, val)))
201 		return hr;
202 	if (FAILED(hr = SafeArrayCopy(aAr, & m_safearray)))
203 		return hr;
204 	return S_OK;
205 }
206 
inoutObject(IDispatch ** val)207 STDMETHODIMP CBasic::inoutObject(IDispatch **val)
208 {
209 	CComPtr<IDispatch> disp = *val;
210 	if (*val)
211 		(*val)->Release();
212 	*val = m_obj;
213 	if (*val)
214 		(*val)->AddRef();
215 	m_obj = disp;
216 	return S_OK;
217 }
218 
219 
outBool(VARIANT_BOOL * val)220 STDMETHODIMP CBasic::outBool(VARIANT_BOOL* val)
221 {
222 	*val = m_bool;
223 	return S_OK;
224 }
225 
outByte(unsigned char * val)226 STDMETHODIMP CBasic::outByte(unsigned char *val)
227 {
228 	*val= m_byte;
229 	return S_OK;
230 }
231 
outShort(short * val)232 STDMETHODIMP CBasic::outShort(short *val)
233 {
234 	*val= m_short;
235 	return S_OK;
236 }
237 
outLong(long * val)238 STDMETHODIMP CBasic::outLong(long *val)
239 {
240 	*val= m_long;
241 	return S_OK;
242 }
243 
outString(BSTR * val)244 STDMETHODIMP CBasic::outString(BSTR *val)
245 {
246 	*val= SysAllocString(m_bstr);
247 	return S_OK;
248 }
249 
outFloat(float * val)250 STDMETHODIMP CBasic::outFloat(float *val)
251 {
252 	*val= m_float;
253 	return S_OK;
254 }
255 
outDouble(double * val)256 STDMETHODIMP CBasic::outDouble(double *val)
257 {
258 	*val= m_double;
259 	return S_OK;
260 }
261 
outVariant(VARIANT * val)262 STDMETHODIMP CBasic::outVariant(VARIANT *val)
263 {
264 	HRESULT hr = S_OK;
265 	if (FAILED(hr = VariantCopy(val, &m_var1)))
266 		return hr;
267 	return S_OK;
268 }
269 
outArray(LPSAFEARRAY * val)270 STDMETHODIMP CBasic::outArray(LPSAFEARRAY *val)
271 {
272 	HRESULT hr = S_OK;
273 	if (FAILED(hr = SafeArrayCopy(m_safearray, val)))
274 		return false;
275 	return S_OK;
276 }
277 
outObject(IDispatch ** val)278 STDMETHODIMP CBasic::outObject(IDispatch* *val)
279 {
280 	*val = m_obj;
281 	if (m_obj)
282 		(*val)->AddRef();
283 
284 	return S_OK;
285 }
286 
287 
get_prpBool(VARIANT_BOOL * pVal)288 STDMETHODIMP CBasic::get_prpBool(VARIANT_BOOL* pVal)
289 {
290 	if (!pVal) return E_POINTER;
291 	*pVal = m_bool;
292 	return S_OK;
293 }
294 
put_prpBool(VARIANT_BOOL val)295 STDMETHODIMP CBasic::put_prpBool(VARIANT_BOOL val)
296 {
297 	m_bool = val;
298 	return S_OK;
299 }
300 
301 
get_prpByte(unsigned char * pVal)302 STDMETHODIMP CBasic::get_prpByte(unsigned char *pVal)
303 {
304 	if( !pVal)
305 		return E_POINTER;
306 	*pVal= m_cPrpByte;
307 	return S_OK;
308 }
309 
put_prpByte(unsigned char newVal)310 STDMETHODIMP CBasic::put_prpByte(unsigned char newVal)
311 {
312 	m_cPrpByte= newVal;
313 	return S_OK;
314 }
315 
get_prpShort(short * pVal)316 STDMETHODIMP CBasic::get_prpShort(short *pVal)
317 {
318 	if( !pVal)
319 		return E_POINTER;
320 	*pVal= m_nPrpShort;
321 	return S_OK;
322 }
323 
put_prpShort(short newVal)324 STDMETHODIMP CBasic::put_prpShort(short newVal)
325 {
326 	m_nPrpShort= newVal;
327 	return S_OK;
328 }
329 
get_prpLong(long * pVal)330 STDMETHODIMP CBasic::get_prpLong(long *pVal)
331 {
332 	if( !pVal)
333 		return E_POINTER;
334 	*pVal= m_lPrpLong;
335 	return S_OK;
336 }
337 
put_prpLong(long newVal)338 STDMETHODIMP CBasic::put_prpLong(long newVal)
339 {
340 	m_lPrpLong= newVal;
341 	return S_OK;
342 }
343 
get_prpString(BSTR * pVal)344 STDMETHODIMP CBasic::get_prpString(BSTR *pVal)
345 {
346 	if( !pVal)
347 		return E_POINTER;
348 	m_bstrPrpString.CopyTo( pVal );
349 	return S_OK;
350 }
351 
put_prpString(BSTR newVal)352 STDMETHODIMP CBasic::put_prpString(BSTR newVal)
353 {
354 	m_bstrPrpString= newVal;
355 	return S_OK;
356 }
357 
get_prpFloat(float * pVal)358 STDMETHODIMP CBasic::get_prpFloat(float *pVal)
359 {
360 	if( !pVal)
361 		return E_POINTER;
362 	*pVal= m_fPrpFloat;
363 	return S_OK;
364 }
365 
put_prpFloat(float newVal)366 STDMETHODIMP CBasic::put_prpFloat(float newVal)
367 {
368 	m_fPrpFloat= newVal;
369 	return S_OK;
370 }
371 
get_prpDouble(double * pVal)372 STDMETHODIMP CBasic::get_prpDouble(double *pVal)
373 {
374 	if( !pVal)
375 		return E_POINTER;
376 	*pVal= m_dPrpDouble;
377 	return S_OK;
378 }
379 
put_prpDouble(double newVal)380 STDMETHODIMP CBasic::put_prpDouble(double newVal)
381 {
382 	m_dPrpDouble= newVal;
383 	return S_OK;
384 }
385 
get_prpVariant(VARIANT * pVal)386 STDMETHODIMP CBasic::get_prpVariant(VARIANT *pVal)
387 {
388 	if( !pVal)
389 		return E_POINTER;
390 	HRESULT hr = S_OK;
391 	if (FAILED(hr = VariantCopy( pVal, &m_PropVariant)))
392 		return hr;
393 	return hr;
394 }
395 
put_prpVariant(VARIANT newVal)396 STDMETHODIMP CBasic::put_prpVariant(VARIANT newVal)
397 {
398 	m_PropVariant= newVal;
399 	return S_OK;
400 }
401 
get_prpArray(LPSAFEARRAY * pVal)402 STDMETHODIMP CBasic::get_prpArray(LPSAFEARRAY *pVal)
403 {
404 	if( !pVal)
405 		return E_POINTER;
406 	HRESULT hr = S_OK;
407 	if (FAILED(hr = SafeArrayCopy( m_PrpArray, pVal)))
408 		return hr;
409 	return hr;
410 }
411 
put_prpArray(LPSAFEARRAY newVal)412 STDMETHODIMP CBasic::put_prpArray(LPSAFEARRAY newVal)
413 {
414 	HRESULT hr = S_OK;
415 	if (FAILED(hr = SafeArrayDestroy( m_PrpArray)))
416 		return hr;
417 	if (FAILED(hr = SafeArrayCopy( newVal, &m_PrpArray)))
418 		return hr;
419 	return hr;
420 }
421 
get_prpObject(IDispatch ** pVal)422 STDMETHODIMP CBasic::get_prpObject(IDispatch **pVal)
423 {
424 	if( !pVal)
425 		return E_POINTER;
426 	*pVal= m_PrpObject;
427 	if( *pVal != NULL)
428 		(*pVal)->AddRef();
429 	return S_OK;
430 }
431 
put_prpObject(IDispatch * newVal)432 STDMETHODIMP CBasic::put_prpObject(IDispatch *newVal)
433 {
434 	m_PrpObject= newVal;
435 	return S_OK;
436 }
437 
mixed1(unsigned char * aChar,float * aFloat,VARIANT * aVar)438 STDMETHODIMP CBasic::mixed1(
439             /* [out][in] */ unsigned char *aChar,
440 			/* [out][in] */ float *aFloat,
441             /* [out][in] */ VARIANT *aVar)
442 
443 {
444 	HRESULT hr= S_OK;
445 	inoutByte(aChar);
446 	inoutFloat(aFloat);
447 	inoutVariant(aVar);
448 	return hr;
449 }
450 
451 
452 
453 
454 // VT_UI1
455 
inSequenceLong(LPSAFEARRAY val)456 STDMETHODIMP CBasic::inSequenceLong(LPSAFEARRAY val)
457 {
458 	HRESULT hr = S_OK;
459 	if (FAILED(hr = SafeArrayDestroy(m_arLong)))
460 		return hr;
461 	if (FAILED(hr = SafeArrayCopy(val, & m_arLong)))
462 		return hr;
463 	return hr;
464 }
465 
inSequenceByte(LPSAFEARRAY val)466 STDMETHODIMP CBasic::inSequenceByte( LPSAFEARRAY val)
467 {
468 	HRESULT hr = S_OK;
469 	if (FAILED(hr = SafeArrayDestroy(m_arByte)))
470 		return hr;
471 	if (FAILED(hr = SafeArrayCopy(val, & m_arByte)))
472 		return hr;
473 	return hr;
474 }
475 
inSequenceShort(LPSAFEARRAY val)476 STDMETHODIMP CBasic::inSequenceShort(LPSAFEARRAY val)
477 {
478 	HRESULT hr = S_OK;
479 	if (FAILED(hr = SafeArrayDestroy(m_arShort)))
480 		return hr;
481 	if (FAILED(hr = SafeArrayCopy(val, & m_arShort)))
482 		return hr;
483 	return hr;
484 }
485 
inSequenceString(LPSAFEARRAY val)486 STDMETHODIMP CBasic::inSequenceString(LPSAFEARRAY val)
487 {
488 	HRESULT hr = S_OK;
489 	if (FAILED(hr = SafeArrayDestroy(m_arString)))
490 		return hr;
491 	if (FAILED(hr = SafeArrayCopy(val, & m_arString)))
492 		return hr;
493 	return hr;
494 }
495 
inSequenceFloat(LPSAFEARRAY val)496 STDMETHODIMP CBasic::inSequenceFloat(LPSAFEARRAY val)
497 {
498 	HRESULT hr = S_OK;
499 	if (FAILED(hr = SafeArrayDestroy(m_arFloat)))
500 		return hr;
501 	if (FAILED(hr = SafeArrayCopy(val, & m_arFloat)))
502 		return hr;
503 	return hr;
504 }
505 
inSequenceDouble(LPSAFEARRAY val)506 STDMETHODIMP CBasic::inSequenceDouble(LPSAFEARRAY val)
507 {
508 	HRESULT hr = S_OK;
509 	if (FAILED(hr = SafeArrayDestroy(m_arDouble)))
510 		return hr;
511 	if (FAILED(hr = SafeArrayCopy(val, & m_arDouble)))
512 		return hr;
513 	return hr;
514 }
515 
inSequenceObject(LPSAFEARRAY val)516 STDMETHODIMP CBasic::inSequenceObject(LPSAFEARRAY val)
517 {
518 	HRESULT hr = S_OK;
519 	if (FAILED(hr = SafeArrayDestroy(m_arObject)))
520 		return hr;
521 	if (FAILED(hr = SafeArrayCopy(val, & m_arObject)))
522 		return hr;
523 	return hr;
524 }
525 
printArray(LPSAFEARRAY val,BSTR message,VARTYPE type)526 void CBasic::printArray( LPSAFEARRAY val, BSTR message, VARTYPE type)
527 {
528 
529 	HRESULT hr= S_OK;
530 	USES_CONVERSION;
531 	long lbound=0;
532 	long ubound= 0;
533 	hr= SafeArrayGetLBound( val, 1, &lbound);
534 	hr= SafeArrayGetUBound( val, 1, &ubound);
535 	long length= ubound - lbound +1;
536 
537 	CComVariant varElement;
538 	char buf[1024];
539 	sprintf( buf,"%s", W2A(message));
540 
541 	for( long i= 0; i < length ; i++)
542 	{
543 		char tmp[1024];
544 		long data=0;
545 		CComVariant var;
546 		switch( type)
547 		{
548 		case VT_UI1:
549 		case VT_I2:
550 		case VT_I4:
551 		case VT_ERROR:
552 			hr= SafeArrayGetElement( val, &i, (void*)&data);
553 			sprintf( tmp, "%d \n", *(long*)&data);
554 			break;
555 		case VT_BSTR:
556 			hr= SafeArrayGetElement( val, &i, (void*)&data);
557 			sprintf( tmp, "%S \n", (BSTR)data);
558 			break;
559 		case VT_VARIANT:
560 			hr= SafeArrayGetElement( val, &i, &var);
561 			sprintf( tmp, "%x \n", var.byref);
562 			break;
563 		case VT_R4:
564 			hr= SafeArrayGetElement( val, &i, (void*)&data);
565 			sprintf( tmp, "%f \n", *(float*) &data);
566 			break;
567 		case VT_R8: ;
568 			hr= SafeArrayGetElement( val, &i, (void*)&data);
569 			sprintf( tmp, "%f \n", *(double*) &data);
570 			break;
571 		case VT_DISPATCH:
572 			// we assume the objects are instances of this component and have the
573 			// property prpString set.
574 			hr= SafeArrayGetElement( val, &i, (void*)&data);
575 			IDispatch* pdisp= ( IDispatch*) data;
576 			CComDispatchDriver driver( pdisp);
577 			CComVariant var;
578 			if( pdisp)
579 			{
580 				driver.GetPropertyByName(L"prpString", &var);
581 				sprintf( tmp, "%x : %S \n", *(long*)&data, var.bstrVal);
582 			}
583 			else
584 				sprintf( tmp, "%x\n", *(long*)&data);
585 		}
586 
587 		strcat( buf, tmp);
588 	}
589 	MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK);
590 
591 }
592 // V_ERROR OLECHAR VARIANT VT_UI1
593 
outSequenceByte(LPSAFEARRAY * val)594 STDMETHODIMP CBasic::outSequenceByte(LPSAFEARRAY* val)
595 {
596 	HRESULT hr= S_OK;
597 	hr = SafeArrayCopy(m_arByte, val);
598 	return hr;
599 }
600 
outSequenceShort(LPSAFEARRAY * val)601 STDMETHODIMP CBasic::outSequenceShort(LPSAFEARRAY* val)
602 {
603 	HRESULT hr= S_OK;
604 	hr = SafeArrayCopy(m_arShort, val);
605 	return hr;
606 }
607 
outSequenceLong(LPSAFEARRAY * val)608 STDMETHODIMP CBasic::outSequenceLong(LPSAFEARRAY* val)
609 {
610 	HRESULT hr= S_OK;
611 	hr = SafeArrayCopy(m_arLong, val);
612 	return hr;
613 }
614 
outSequenceString(LPSAFEARRAY * val)615 STDMETHODIMP CBasic::outSequenceString(LPSAFEARRAY* val)
616 {
617 	HRESULT hr= S_OK;
618 	hr = SafeArrayCopy(m_arString, val);
619 	return hr;
620 }
621 
outSequenceFloat(LPSAFEARRAY * val)622 STDMETHODIMP CBasic::outSequenceFloat(LPSAFEARRAY* val)
623 {
624 	HRESULT hr= S_OK;
625 	hr = SafeArrayCopy(m_arFloat, val);
626 	return hr;
627 }
628 
outSequenceDouble(LPSAFEARRAY * val)629 STDMETHODIMP CBasic::outSequenceDouble(LPSAFEARRAY* val)
630 {
631 	HRESULT hr= S_OK;
632 	hr = SafeArrayCopy(m_arDouble, val);
633 	return hr;
634 }
635 
outSequenceObject(LPSAFEARRAY * val)636 STDMETHODIMP CBasic::outSequenceObject(LPSAFEARRAY* val)
637 {
638 	HRESULT hr = S_OK;
639 	hr = SafeArrayCopy(m_arObject, val);
640 	return S_OK;
641 }
642 
inoutSequenceByte(LPSAFEARRAY * val)643 STDMETHODIMP CBasic::inoutSequenceByte(LPSAFEARRAY* val)
644 {
645 	HRESULT hr = S_OK;
646 	SAFEARRAY *arTemp = NULL;
647 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
648 		return hr;
649 	if (FAILED(hr = SafeArrayCopy(m_arByte, val)))
650 		return hr;
651 	m_arByte = arTemp;
652 	return hr;
653 }
654 
inoutSequenceShort(LPSAFEARRAY * val)655 STDMETHODIMP CBasic::inoutSequenceShort(LPSAFEARRAY* val)
656 {
657 	HRESULT hr = S_OK;
658 	SAFEARRAY *arTemp = NULL;
659 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
660 		return hr;
661 	if (FAILED(hr = SafeArrayCopy(m_arShort, val)))
662 		return hr;
663 	m_arShort = arTemp;
664 	return hr;
665 }
666 
inoutSequenceLong(LPSAFEARRAY * val)667 STDMETHODIMP CBasic::inoutSequenceLong(LPSAFEARRAY* val)
668 {
669 	HRESULT hr = S_OK;
670 	SAFEARRAY *arTemp = NULL;
671 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
672 		return hr;
673 	if (FAILED(hr = SafeArrayCopy(m_arLong, val)))
674 		return hr;
675 	m_arLong = arTemp;
676 	return hr;
677 }
678 
inoutSequenceString(LPSAFEARRAY * val)679 STDMETHODIMP CBasic::inoutSequenceString(LPSAFEARRAY* val)
680 {
681 	HRESULT hr = S_OK;
682 	SAFEARRAY *arTemp = NULL;
683 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
684 		return hr;
685 	if (FAILED(hr = SafeArrayCopy(m_arString, val)))
686 		return hr;
687 	m_arString = arTemp;
688 	return hr;
689 }
690 
inoutSequenceFloat(LPSAFEARRAY * val)691 STDMETHODIMP CBasic::inoutSequenceFloat(LPSAFEARRAY* val)
692 {
693 	HRESULT hr = S_OK;
694 	SAFEARRAY *arTemp = NULL;
695 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
696 		return hr;
697 	if (FAILED(hr = SafeArrayCopy(m_arFloat, val)))
698 		return hr;
699 	m_arFloat = arTemp;
700 	return hr;
701 }
702 
inoutSequenceDouble(LPSAFEARRAY * val)703 STDMETHODIMP CBasic::inoutSequenceDouble(LPSAFEARRAY* val)
704 {
705 	HRESULT hr = S_OK;
706 	SAFEARRAY *arTemp = NULL;
707 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
708 		return hr;
709 	if (FAILED(hr = SafeArrayCopy(m_arDouble, val)))
710 		return hr;
711 	m_arDouble = arTemp;
712 	return hr;
713 }
714 
inoutSequenceObject(LPSAFEARRAY * val)715 STDMETHODIMP CBasic::inoutSequenceObject(LPSAFEARRAY* val)
716 {
717 	HRESULT hr = S_OK;
718 	SAFEARRAY *arTemp = NULL;
719 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
720 		return hr;
721 	if (FAILED(hr = SafeArrayCopy(m_arObject, val)))
722 		return hr;
723 	m_arObject = arTemp;
724 	return hr;
725 }
726 
727 // 2-dimensional Array
inMulDimArrayLong(LPSAFEARRAY val)728 STDMETHODIMP CBasic::inMulDimArrayLong(LPSAFEARRAY val)
729 {
730 	printMulArray( val, VT_I4);
731 	return S_OK;
732 }
733 // 2-dimensional Array
inMulDimArrayVariant(LPSAFEARRAY val)734 STDMETHODIMP CBasic::inMulDimArrayVariant(LPSAFEARRAY val)
735 {
736 	printMulArray( val, VT_VARIANT);
737 	return S_OK;
738 }
739 // 3-dimensional Array
inMulDimArrayLong2(LPSAFEARRAY val)740 STDMETHODIMP CBasic::inMulDimArrayLong2(LPSAFEARRAY val)
741 {
742 	printMulArray( val, VT_I4);
743 	return S_OK;
744 }
745 // 3-dimensional Array
inMulDimArrayVariant2(LPSAFEARRAY val)746 STDMETHODIMP CBasic::inMulDimArrayVariant2(LPSAFEARRAY val)
747 {
748 	return S_OK;
749 }
750 
751 
inMulDimArrayByte(LPSAFEARRAY val)752 STDMETHODIMP CBasic::inMulDimArrayByte(LPSAFEARRAY val)
753 {
754 	HRESULT hr = S_OK;
755 	if (FAILED(hr = SafeArrayDestroy(m_arByteDim2)))
756 		return hr;
757 	if (FAILED(hr = SafeArrayCopy(val, & m_arByteDim2)))
758 		return hr;
759 	return hr;
760 }
761 // 3-dimensionales array
inMulDimArrayByte2(LPSAFEARRAY val)762 STDMETHODIMP CBasic::inMulDimArrayByte2(LPSAFEARRAY val)
763 {
764 
765 	// TODO: Add your implementation code here
766 	//printMulArray( val, VT_UI1);
767 	return S_OK;
768 }
769 
770 // supports 2 and 3 dimensionals SAFEARRAY with elements of long or VARIANT
printMulArray(SAFEARRAY * val,VARTYPE type)771 void CBasic::printMulArray( SAFEARRAY* val, VARTYPE type)
772 {
773 	HRESULT hr= S_OK;
774 	UINT dims= SafeArrayGetDim( val);
775 	long lbound1;
776 	long ubound1;
777 	long lbound2;
778 	long ubound2;
779 	long lbound3;
780 	long ubound3;
781 	long length1;
782 	long length2;
783 	long length3;
784 
785 	char buff[4096];
786 	buff[0]=0;
787 
788 	if( dims == 2)
789 	{
790 		hr= SafeArrayGetLBound( val, 1, &lbound1);
791 		hr= SafeArrayGetUBound( val, 1, &ubound1);
792 		length1= ubound1 - lbound1 +1;
793 
794 		hr= SafeArrayGetLBound( val, 2, &lbound2);
795 		hr= SafeArrayGetUBound( val, 2, &ubound2);
796 		length2= ubound2 - lbound2 + 1;
797 		char tmpBuf[1024];
798 		tmpBuf[0]=0;
799 		long index[2];
800 		for( long i= 0; i< length2; i++)
801 		{
802 			for( long j= 0; j<length1; j++)
803 			{
804 				index[0]= j;
805 				index[1]= i;
806 				long longVal;
807 				CComVariant var;
808 				switch( type)
809 				{
810 				case VT_I4:
811 					hr= SafeArrayGetElement( val, index, &longVal);
812 					sprintf( tmpBuf, "(%d,%d): %d\n", index[1], index[0], longVal);
813 					break;
814 				case VT_UI1:
815 					hr= SafeArrayGetElement( val, index, &longVal);
816 					sprintf( tmpBuf, "(%d,%d): %d\n", index[1], index[0], (unsigned char)longVal);
817 					break;
818 				case VT_VARIANT:
819 					hr= SafeArrayGetElement( val, index, &var );
820 					sprintf( tmpBuf, "(%d,%d):  %d (vartype %d)\n",  index[1], index[0], var.byref, var.vt);
821 					break;
822 				}
823 				strcat( buff,tmpBuf);
824 			}
825 
826 		}
827 
828 
829 	}
830 	else if( dims == 3 )
831 	{
832 		hr= SafeArrayGetLBound( val, 1, &lbound1);
833 		hr= SafeArrayGetUBound( val, 1, &ubound1);
834 		length1= ubound1 - lbound1 +1;
835 
836 		hr= SafeArrayGetLBound( val, 2, &lbound2);
837 		hr= SafeArrayGetUBound( val, 2, &ubound2);
838 		length2= ubound2 - lbound2 + 1;
839 
840 		hr= SafeArrayGetLBound( val, 3, &lbound3);
841 		hr= SafeArrayGetUBound( val, 3, &ubound3);
842 		length3= ubound3 - lbound3 +1;
843 		char tmpBuf[1024];
844 		tmpBuf[0]=0;
845 		long index[3];
846 		for( long i= 0; i< length3; i++)
847 		{
848 			for( long j= 0; j<length2; j++)
849 			{
850 				for( long k= 0; k<length1; k++)
851 				{
852 					index[0]= k;
853 					index[1]= j;
854 					index[2]= i;
855 					long longVal;
856 					CComVariant var;
857 					switch( type)
858 					{
859 					case VT_I4:
860 						hr= SafeArrayGetElement( val, index, &longVal);
861 						sprintf( tmpBuf, "(%d,%d,%d): %d\n", index[2], index[1], index[0], longVal);
862 						break;
863 					case VT_UI1:
864 						hr= SafeArrayGetElement( val, index, &longVal);
865 						sprintf( tmpBuf, "(%d,%d,%d): %d\n", index[2], index[1], index[0], (unsigned char)longVal);
866 						break;
867 
868 					case VT_VARIANT:
869 						hr= SafeArrayGetElement( val, index, &var );
870 						sprintf( tmpBuf, "(%d,%d,%d):  %d (vartype %d)\n", index[2],  index[1], index[0], var.byref, var.vt);
871 						break;
872 					}
873 					strcat( buff,tmpBuf);
874 				}
875 			}
876 
877 		}
878 
879 	}
880 
881 	MessageBox( NULL, A2T( buff), _T("AxTestControl.Basic"), MB_OK);
882 
883 
884 }
885 
886 
887 
888 
outMore(long * val1,long * val2)889 STDMETHODIMP CBasic::outMore(long* val1, long* val2)
890 {
891 	// TODO: Add your implementation code here
892 	*val1= 111;
893 	*val2= 112;
894 	return S_OK;
895 }
896 // If an optional parameter was not provided then the respective member will
897 // not be set
optional1(long val1,VARIANT * val2)898 STDMETHODIMP CBasic::optional1(/*[in]*/ long val1, /*[in, optional]*/ VARIANT* val2)
899 {
900 	m_long = val1;
901 	if (val2->vt != VT_ERROR)
902 		m_var1 = *val2;
903 	return S_OK;
904 }
905 
optional2(long * val1,VARIANT * val2)906 STDMETHODIMP CBasic::optional2(/*[out]*/ long* val1,/*[out, optional]*/ VARIANT* val2)
907 {
908 	HRESULT hr = S_OK;
909 	*val1 = m_long;
910 
911 	if (val2->vt != VT_ERROR)
912 		hr = VariantCopy(val2, & m_var1);
913 	return hr;
914 }
915 
optional3(VARIANT * val1,VARIANT * val2)916 STDMETHODIMP CBasic::optional3(/*[in, optional]*/ VARIANT* val1,/*[in, optional]*/ VARIANT* val2)
917 {
918 	//if (val1->vt != VT_ERROR)
919 		m_var1 = *val1;
920 
921 	//if (val2->vt != VT_ERROR)
922 		m_var2 = *val2;
923 	return S_OK;
924 }
925 
optional4(VARIANT * val1,VARIANT * val2)926 STDMETHODIMP CBasic::optional4(/*[in, out, optional]*/ VARIANT* val1,
927 							   /*[in, out, optional]*/ VARIANT* val2)
928 {
929 	HRESULT hr = S_OK;
930 	//return the previously set in values
931 	if (val1->vt != VT_ERROR)
932 	{
933 		CComVariant var1(*val1);
934 		if (FAILED(hr = VariantCopy(val1, & m_var1)))
935 			return hr;
936 		m_var1 = var1;
937 	}
938 	if (val2->vt != VT_ERROR)
939 	{
940 		CComVariant var2(*val2);
941 		if (FAILED(hr = VariantCopy(val2, & m_var2)))
942 			return hr;
943 		m_var2 = var2;
944 	}
945 	return hr;
946 }
947 
optional5(VARIANT * val1,VARIANT * val2)948 STDMETHODIMP CBasic::optional5(/*[out, optional]*/ VARIANT* val1,
949 							   /*[out, optional]*/ VARIANT* val2)
950 {
951 	HRESULT hr = S_OK;
952 	if (FAILED(hr = VariantCopy(val1, &m_var1)))
953 		return hr;
954 	if (FAILED(hr = VariantCopy(val2, &m_var2)))
955 		return hr;
956 	return hr;
957 }
958 
defaultvalue1(long val1,double * val2,VARIANT * val4)959 STDMETHODIMP CBasic::defaultvalue1(/*[in, defaultvalue(10)]*/ long val1,
960 								   /*[in, defaultvalue(3.14)]*/ double* val2,
961 								//   /*[in, defaultvalue(10)]*/ VARIANT val3,
962 							       /*[in, defaultvalue(100)]*/ VARIANT* val4)
963 {
964 	m_long = val1;
965 	m_double = *val2;
966 //	m_var1 = val3;
967 	m_var2 = *val4;
968 	return S_OK;
969 }
defaultvalue2(long * val1,double * val2,VARIANT * val4)970 STDMETHODIMP CBasic::defaultvalue2(/*[in, out, defaultvalue(10)]*/ long* val1,
971 								   /*[in, out, defaultvalue(3.14)]*/ double* val2,
972 								//   /*[in, out, defaultvalue(10)]*/ VARIANT* val3,
973 							       /*[in, out, defaultvalue(100)]*/ VARIANT* val4)
974 {
975 	HRESULT hr = S_OK;
976 	long aLong = *val1;
977 	double aDouble = *val2;
978 //	CComVariant var1(*val3);
979 	CComVariant var2(*val4);
980 	*val1 = m_long;
981 	*val2 = m_double;
982 	//if (FAILED(hr = VariantCopy(val3, &m_var1)))
983 	//	return hr;
984 	if (FAILED(hr = VariantCopy(val4, &m_var2)))
985 		return hr;
986 	m_long = aLong;
987 	m_double = aDouble;
988 //	m_var1 = var1;
989 	m_var2 = var2;
990 	return hr;
991 }
992 /* val2 contains the variable argument list. If no such arguments are supplied
993 	then the safearray is invalid. SafeArrayCopy then returns E_INVALIDARG
994 */
varargfunc1(long val1,LPSAFEARRAY val2)995 STDMETHODIMP CBasic::varargfunc1(/*[in]*/ long val1,/*[in]*/ LPSAFEARRAY val2)
996 {
997 	m_long = val1;
998 
999 	HRESULT hr = S_OK;
1000 	if (FAILED(hr = SafeArrayDestroy(m_safearray)))
1001 		return hr;
1002 	if (FAILED(hr = SafeArrayCopy(val2, & m_safearray)))
1003 	{
1004 		if (hr != E_INVALIDARG)
1005 			return hr;
1006 	}
1007 	return S_OK;
1008 }
1009 
varargfunc2(long * val1,SAFEARRAY ** val2)1010 STDMETHODIMP CBasic::varargfunc2(/*[out]*/ long* val1, /*[out]*/ SAFEARRAY ** val2)
1011 {
1012 	*val1 = m_long;
1013 	HRESULT hr = SafeArrayCopy(m_safearray, val2);
1014 	return hr;
1015 }
1016 
inSequenceByteDim2(LPSAFEARRAY val)1017 STDMETHODIMP CBasic::inSequenceByteDim2(LPSAFEARRAY val)
1018 {
1019 	HRESULT hr = S_OK;
1020 	if (FAILED(hr = SafeArrayDestroy(m_arByteDim2)))
1021 		return hr;
1022 	if (FAILED(hr = SafeArrayCopy(val, & m_arByteDim2)))
1023 		return hr;
1024 	return hr;
1025 }
1026 
1027 
inCurrency(CY val)1028 STDMETHODIMP CBasic::inCurrency(CY val)
1029 {
1030 	m_cy = val;
1031 	return S_OK;
1032 }
1033 
outCurrency(CY * val)1034 STDMETHODIMP CBasic::outCurrency(CY* val)
1035 {
1036 	*val = m_cy;
1037 	return S_OK;
1038 }
1039 
inoutCurrency(CY * val)1040 STDMETHODIMP CBasic::inoutCurrency(CY* val)
1041 {
1042 	CY tmp = *val;
1043 	*val = m_cy;
1044 	m_cy = tmp;
1045 	return S_OK;
1046 }
1047 
inDate(DATE val)1048 STDMETHODIMP CBasic::inDate(DATE val)
1049 {
1050 	m_date = val;
1051 	return S_OK;
1052 }
1053 
outDate(DATE * val)1054 STDMETHODIMP CBasic::outDate(DATE* val)
1055 {
1056 	*val = m_date;
1057 	return S_OK;
1058 }
1059 
inoutDate(DATE * val)1060 STDMETHODIMP CBasic::inoutDate(DATE* val)
1061 {
1062 	DATE tmp = *val;
1063 	*val = m_date;
1064 	m_date = tmp;
1065 	return S_OK;
1066 }
1067 
get_prpCurrency(CY * pVal)1068 STDMETHODIMP CBasic::get_prpCurrency(CY* pVal)
1069 {
1070 	*pVal = m_cy;
1071 	return S_OK;
1072 }
1073 
put_prpCurrency(CY newVal)1074 STDMETHODIMP CBasic::put_prpCurrency(CY newVal)
1075 {
1076 	m_cy = newVal;
1077 	return S_OK;
1078 }
1079 
get_prpDate(DATE * pVal)1080 STDMETHODIMP CBasic::get_prpDate(DATE* pVal)
1081 {
1082 	*pVal = m_date;
1083 	return S_OK;
1084 }
1085 
put_prpDate(DATE newVal)1086 STDMETHODIMP CBasic::put_prpDate(DATE newVal)
1087 {
1088 	m_date = newVal;
1089 	return S_OK;
1090 }
1091 
1092 //VT_I4 DECIMAL_NEG //tagVARIANT DISPATCH_PROPERTYPUT
inDecimal(DECIMAL val)1093 STDMETHODIMP CBasic::inDecimal(DECIMAL val)
1094 {
1095 	m_decimal = val;
1096 	return S_OK;
1097 }
1098 
outDecimal(DECIMAL * val)1099 STDMETHODIMP CBasic::outDecimal(DECIMAL* val)
1100 {
1101 	* val = m_decimal;
1102 	return S_OK;
1103 }
1104 
inoutDecimal(DECIMAL * val)1105 STDMETHODIMP CBasic::inoutDecimal(DECIMAL* val)
1106 {
1107 	DECIMAL tmp;
1108 	tmp = * val;
1109 	* val = m_decimal;
1110 	m_decimal = tmp;
1111 	return S_OK;
1112 }
1113 
get_prpDecimal(DECIMAL * pVal)1114 STDMETHODIMP CBasic::get_prpDecimal(DECIMAL* pVal)
1115 {
1116 	* pVal = m_decimal;
1117 	return S_OK;
1118 }
1119 
put_prpDecimal(DECIMAL newVal)1120 STDMETHODIMP CBasic::put_prpDecimal(DECIMAL newVal)
1121 {
1122 	m_decimal = newVal;
1123 	return S_OK;
1124 }
1125 
inSCode(SCODE val)1126 STDMETHODIMP CBasic::inSCode(SCODE val)
1127 {
1128 	m_scode = val;
1129 	return S_OK;
1130 }
1131 
outScode(SCODE * val)1132 STDMETHODIMP CBasic::outScode(SCODE* val)
1133 {
1134 	* val = m_scode;
1135 	return S_OK;
1136 }
1137 
inoutSCode(SCODE * val)1138 STDMETHODIMP CBasic::inoutSCode(SCODE* val)
1139 {
1140 	SCODE tmp = *val;
1141 	* val = m_scode;
1142 	m_scode = tmp;
1143 	return S_OK;
1144 }
1145 
get_prpSCode(SCODE * pVal)1146 STDMETHODIMP CBasic::get_prpSCode(SCODE* pVal)
1147 {
1148 	* pVal = m_scode;
1149 	return S_OK;
1150 }
1151 
put_prpSCode(SCODE newVal)1152 STDMETHODIMP CBasic::put_prpSCode(SCODE newVal)
1153 {
1154 	m_scode = newVal;
1155 	return S_OK;
1156 }
1157 
inrefLong(LONG * val)1158 STDMETHODIMP CBasic::inrefLong(LONG* val)
1159 {
1160 	m_long = * val;
1161 	return S_OK;
1162 }
1163 
inrefVariant(VARIANT * val)1164 STDMETHODIMP CBasic::inrefVariant(VARIANT* val)
1165 {
1166 	HRESULT hr = S_OK;
1167 	if (FAILED(hr = VariantCopy( & m_var1, val)))
1168 		return hr;
1169 	return S_OK;
1170 }
1171 
inrefDecimal(DECIMAL * val)1172 STDMETHODIMP CBasic::inrefDecimal(DECIMAL* val)
1173 {
1174 	m_decimal = * val;
1175 	return S_OK;
1176 }
1177 
get_prpRefLong(long * pVal)1178 STDMETHODIMP CBasic::get_prpRefLong(long* pVal)
1179 {
1180 	*pVal = m_long;
1181 	return S_OK;
1182 }
1183 
putref_prpRefLong(long * newVal)1184 STDMETHODIMP CBasic::putref_prpRefLong(long* newVal)
1185 {
1186 	m_long = * newVal;
1187 	return S_OK;
1188 }
1189 
get_prprefVariant(VARIANT * pVal)1190 STDMETHODIMP CBasic::get_prprefVariant(VARIANT* pVal)
1191 {
1192 	HRESULT hr = S_OK;
1193 	hr = VariantCopy(pVal, & m_var1);
1194 	return hr;
1195 }
1196 
putref_prprefVariant(VARIANT * newVal)1197 STDMETHODIMP CBasic::putref_prprefVariant(VARIANT* newVal)
1198 {
1199 	m_var1 = * newVal;
1200 	return S_OK;
1201 }
1202 
get_prprefDecimal(DECIMAL * pVal)1203 STDMETHODIMP CBasic::get_prprefDecimal(DECIMAL* pVal)
1204 {
1205 	* pVal = m_decimal;
1206 	return S_OK;
1207 }
1208 
putref_prprefDecimal(DECIMAL * newVal)1209 STDMETHODIMP CBasic::putref_prprefDecimal(DECIMAL* newVal)
1210 {
1211 	m_decimal = *newVal;
1212 	return S_OK;
1213 }
1214 
1215 
optional6(VARIANT * val1,VARIANT * val2,VARIANT * val3,VARIANT * val4)1216 STDMETHODIMP CBasic::optional6(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4)
1217 {
1218 	HRESULT hr = S_OK;
1219 	if (FAILED(hr = m_var1.Copy(val1)))
1220 		return hr;
1221 	if (FAILED(hr = m_var2.Copy(val2)))
1222 		return hr;
1223 	if (FAILED(hr = m_var3.Copy(val3)))
1224 		return hr;
1225 	if (FAILED(hr = m_var4.Copy(val4)))
1226 		return hr;
1227 	return S_OK;
1228 }
1229 
optional7(VARIANT * val1,VARIANT * val2,VARIANT * val3,VARIANT * val4)1230 STDMETHODIMP CBasic::optional7(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4)
1231 {
1232 	HRESULT hr = S_OK;
1233 	if (FAILED(hr = VariantCopy(val1, & m_var1)))
1234 		return hr;
1235 	if (FAILED(hr = VariantCopy(val2, & m_var2)))
1236 		return hr;
1237 	if (FAILED(hr = VariantCopy(val3, & m_var3)))
1238 		return hr;
1239 	if (FAILED(hr = VariantCopy(val4, & m_var4)))
1240 		return hr;
1241 
1242 	return S_OK;
1243 }
1244 
get_prpMultiArg1(VARIANT * val1,VARIANT * val2,VARIANT * pVal)1245 STDMETHODIMP CBasic::get_prpMultiArg1(VARIANT* val1, VARIANT* val2, VARIANT* pVal)
1246 {
1247 	HRESULT hr = S_OK;
1248 	CComVariant tmp1(*val1);
1249 	CComVariant tmp2(*val2);
1250 
1251 	if (FAILED(hr = VariantCopy(val1, & m_var1)))
1252 		return hr;
1253 	if (FAILED(hr = VariantCopy(val2, & m_var2)))
1254 		return hr;
1255 	m_var1 = tmp1;
1256 	m_var2 = tmp2;
1257 	if  (FAILED(hr = VariantCopy(pVal, & m_var3)))
1258 		return hr;
1259 	return S_OK;
1260 }
1261 
put_prpMultiArg1(VARIANT * val1,VARIANT * val2,VARIANT * newVal)1262 STDMETHODIMP CBasic::put_prpMultiArg1(VARIANT* val1, VARIANT* val2, VARIANT* newVal)
1263 {
1264 	HRESULT hr = S_OK;
1265 	CComVariant tmp1( * val1);
1266 	CComVariant tmp2( * val2);
1267 
1268 	if (FAILED(hr = VariantCopy(val1, & m_var1)))
1269 		return hr;
1270 	if (FAILED(hr = VariantCopy(val2, & m_var2)))
1271 		return hr;
1272 	m_var1 = tmp1;
1273 	m_var2 = tmp2;
1274 
1275 	m_var3 = *newVal;
1276 	return S_OK;
1277 }
1278 
1279 // tagVARIANT DISPATCH_PROPERTYPUT DISPID_PROPERTYPUT VARIANTARG LOCALE_USER_DEFAULT
1280 
get_prpMultiArg2(VARIANT val1,VARIANT * pVal)1281 STDMETHODIMP CBasic::get_prpMultiArg2(VARIANT val1, VARIANT* pVal)
1282 {
1283 	HRESULT hr = S_OK;
1284 	m_var1 =  val1;
1285 
1286 	if (FAILED(hr = VariantCopy(pVal, & m_var2)))
1287 		return hr;
1288 	return S_OK;
1289 }
1290 
put_prpMultiArg2(VARIANT val1,VARIANT newVal)1291 STDMETHODIMP CBasic::put_prpMultiArg2(VARIANT val1, VARIANT newVal)
1292 {
1293 	m_var1 = val1;
1294 	m_var2 = newVal;
1295 	return S_OK;
1296 }
1297 
1298 // returns the values set by prpMultiArg2
prpMultiArg2GetValues(VARIANT * val1,VARIANT * valProperty)1299 STDMETHODIMP CBasic::prpMultiArg2GetValues(VARIANT* val1, VARIANT* valProperty)
1300 {
1301 	HRESULT hr = S_OK;
1302 	if (FAILED(VariantCopy(val1, & m_var1)))
1303 		return hr;
1304 	if (FAILED(VariantCopy(valProperty, & m_var2)))
1305 		return hr;
1306 	return S_OK;
1307 }
1308 
get_prpMultiArg3(LONG * val1,LONG * pVal)1309 STDMETHODIMP CBasic::get_prpMultiArg3(LONG* val1, LONG* pVal)
1310 {
1311 	long aLong = *val1;
1312 	*val1 = m_long;
1313 	m_long = aLong;
1314 
1315 	* pVal = m_long2;
1316 	return S_OK;
1317 }
1318 
put_prpMultiArg3(LONG * val1,LONG newVal)1319 STDMETHODIMP CBasic::put_prpMultiArg3(LONG* val1, LONG newVal)
1320 {
1321 	long aLong = *val1;
1322 	*val1 = m_long;
1323 	m_long = aLong;
1324 
1325 	m_long2 = newVal;
1326 	return S_OK;
1327 }
1328 
inUnknown(IUnknown * val)1329 STDMETHODIMP CBasic::inUnknown(IUnknown* val)
1330 {
1331 	m_unknown = val;
1332 
1333 	return S_OK;
1334 }
1335 
outUnknown(IUnknown ** val)1336 STDMETHODIMP CBasic::outUnknown(IUnknown** val)
1337 {
1338 	m_unknown.CopyTo(val);
1339 	return S_OK;
1340 }
1341 
inoutUnknown(IUnknown ** val)1342 STDMETHODIMP CBasic::inoutUnknown(IUnknown** val)
1343 {
1344 	CComPtr<IUnknown> tmp = *val;
1345 	m_unknown.CopyTo(val);
1346 	m_unknown = tmp;
1347 	return S_OK;
1348 }
1349 
get_prpUnknown(IUnknown ** pVal)1350 STDMETHODIMP CBasic::get_prpUnknown(IUnknown** pVal)
1351 {
1352 	m_prpUnknown.CopyTo(pVal);
1353 	return S_OK;
1354 }
1355 
put_prpUnknown(IUnknown * newVal)1356 STDMETHODIMP CBasic::put_prpUnknown(IUnknown* newVal)
1357 {
1358 	m_prpUnknown = newVal;
1359 	return S_OK;
1360 }
1361