1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
/***
*csarray.cpp - Implementation of the CExcepinfo IDispatch test object.
*
* Copyright (C) 1991, Microsoft Corporation. All Rights Reserved.
* Information Contained Herein Is Proprietary and Confidential.
*
*Purpose:
* This file implements the CExcepinfo object, which is used for
* testing the marshaling support for the EXCEPINFO struct passed to
* IDispatch::Invoke().
*
*Revision History:
*
* [00] 02-Dec-92 bradlo: Created.
*
*****************************************************************************/
#include <stdlib.h>
#include "sdisptst.h"
#include "dispdbug.h"
#include "disphelp.h"
#include "cexinfo.h"
ASSERTDATA
STDAPI Excepinfo2DeferredFillIn(EXCEPINFO FAR*);
CExcepinfo::CExcepinfo()
{
m_refs = 0;
m_ptinfo = NULL;
}
/***
*HRESULT CExcepinfo::Create(IUnknown*, IUnknown**)
*Purpose:
* Create and initialize an instance of the CExcepinfo test object.
*
*Entry:
* None
*
*Exit:
* return value = CExcepinfo*. NULL if the creation failed
*
***********************************************************************/
extern "C" INTERFACEDATA g_idataCExcepinfo;
HRESULT
CExcepinfo::Create(IUnknown FAR* punkOuter, IUnknown FAR* FAR* ppunk)
{
HRESULT hresult;
CExcepinfo FAR* pcsa;
ITypeInfo FAR* ptinfo;
if(punkOuter != NULL)
return RESULT(CLASS_E_NOAGGREGATION);
pcsa = new FAR CExcepinfo();
if(pcsa == NULL)
return NULL;
pcsa->AddRef();
hresult =
CreateDispTypeInfo(&g_idataCExcepinfo, LOCALE_SYSTEM_DEFAULT, &ptinfo);
if(HRESULT_FAILED(hresult))
goto LError0;
pcsa->m_ptinfo = ptinfo;
*ppunk = (IUnknown FAR*)pcsa;
IncObjectCount();
return NOERROR;
LError0:;
pcsa->Release();
return NULL;
}
//---------------------------------------------------------------------
// IUnknown Methods
//---------------------------------------------------------------------
STDMETHODIMP
CExcepinfo::QueryInterface(REFIID riid, void FAR* FAR* ppv)
{
if(!IsEqualIID(riid, IID_IUnknown))
if(!IsEqualIID(riid, IID_IDispatch)) {
*ppv = NULL;
return RESULT(E_NOINTERFACE);
}
*ppv = this;
AddRef();
return NOERROR;
}
STDMETHODIMP_(unsigned long)
CExcepinfo::AddRef(void)
{
return ++m_refs;
}
STDMETHODIMP_(unsigned long)
CExcepinfo::Release(void)
{
if(--m_refs == 0){
if(m_ptinfo != NULL)
m_ptinfo->Release();
DecObjectCount();
delete this;
return 0;
}
return m_refs;
}
//---------------------------------------------------------------------
// IDispatch Methods
//---------------------------------------------------------------------
STDMETHODIMP
CExcepinfo::GetTypeInfoCount(unsigned int FAR* pctinfo)
{
*pctinfo = 1;
return NOERROR;
}
STDMETHODIMP
CExcepinfo::GetTypeInfo(
unsigned int itinfo,
LCID lcid,
ITypeInfo FAR* FAR* pptinfo)
{
if(itinfo != 1)
return RESULT(DISP_E_BADINDEX);
if(lcid != LOCALE_SYSTEM_DEFAULT)
return RESULT(DISP_E_UNKNOWNLCID);
m_ptinfo->AddRef();
*pptinfo = m_ptinfo;
return NOERROR;
}
STDMETHODIMP
CExcepinfo::GetIDsOfNames(
REFIID riid,
OLECHAR FAR* FAR* rgszNames,
unsigned int cNames,
LCID lcid,
DISPID FAR* rgdispid)
{
UNUSED(lcid);
if(!IsEqualIID(riid, IID_NULL))
return RESULT(DISP_E_UNKNOWNINTERFACE);
return DispGetIDsOfNames(m_ptinfo, rgszNames, cNames, rgdispid);
}
STDMETHODIMP
CExcepinfo::Invoke(
DISPID dispidMember,
REFIID riid,
LCID lcid,
unsigned short wFlags,
DISPPARAMS FAR* pdispparams,
VARIANT FAR* pvarResult,
EXCEPINFO FAR* pexcepinfo,
unsigned int FAR* puArgErr)
{
UNUSED(lcid);
UNUSED(wFlags);
UNUSED(pdispparams);
UNUSED(pvarResult);
UNUSED(puArgErr);
if(!IsEqualIID(riid, IID_NULL))
return RESULT(DISP_E_UNKNOWNINTERFACE);
DoPrintf("CExcepinfo::Invoke(dispidMember=%ld)\n", dispidMember);
if(pexcepinfo == NULL)
return RESULT(E_INVALIDARG);
switch(dispidMember){
case IDMEMBER_CEXCEPINFO_EXCEPINFO0:
pexcepinfo->wCode = 0;
pexcepinfo->bstrSource = SysAllocString(OLESTR("CExcepinfo::excepinfo0()"));
pexcepinfo->bstrDescription = SysAllocString(OLESTR("exception test #0"));
pexcepinfo->bstrHelpFile = SysAllocString(OLESTR("<help file name #0>"));
pexcepinfo->dwHelpContext = 0L;
return RESULT(DISP_E_EXCEPTION);
case IDMEMBER_CEXCEPINFO_EXCEPINFO1:
pexcepinfo->wCode = 1;
pexcepinfo->bstrSource = SysAllocString(OLESTR("CExcepinfo::excepinfo1()"));
pexcepinfo->bstrDescription = SysAllocString(OLESTR("exception test #1"));
pexcepinfo->bstrHelpFile = SysAllocString(OLESTR("<help file name #1>"));
pexcepinfo->dwHelpContext = 1L;
return RESULT(DISP_E_EXCEPTION);
case IDMEMBER_CEXCEPINFO_EXCEPINFO2:
pexcepinfo->wCode = 2;
pexcepinfo->pfnDeferredFillIn = Excepinfo2DeferredFillIn;
return RESULT(DISP_E_EXCEPTION);
default:
return RESULT(DISP_E_MEMBERNOTFOUND);
}
ASSERT(UNREACHED);
return NOERROR;
}
STDAPI
Excepinfo2DeferredFillIn(EXCEPINFO FAR* pexcepinfo)
{
pexcepinfo->bstrSource = SysAllocString(OLESTR("CExcepinfo::excepinfo2()"));
pexcepinfo->bstrDescription =
SysAllocString(OLESTR("exception test #2 : deferred fillin"));
pexcepinfo->bstrHelpFile = SysAllocString(OLESTR("<help file name #2>"));
pexcepinfo->dwHelpContext = 2L;
return NOERROR;
}
//---------------------------------------------------------------------
// Introduced methods
//---------------------------------------------------------------------
/*
* These are all stubs that should never get called. Nothing happens
* here because the testing work is all done within the implementation
* of CExcepinfo::Invoke().
*
*/
STDMETHODIMP
CExcepinfo::excepinfo0()
{
ASSERT(UNREACHED);
return RESULT(E_UNEXPECTED);
}
STDMETHODIMP
CExcepinfo::excepinfo1()
{
ASSERT(UNREACHED);
return RESULT(E_UNEXPECTED);
}
STDMETHODIMP
CExcepinfo::excepinfo2()
{
ASSERT(UNREACHED);
return RESULT(E_UNEXPECTED);
}
|