This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
disputil.cpp
76 lines (55 loc) · 1.96 KB
/
disputil.cpp
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
#include "stdafx.h"
#include "disputil.h"
void EnumEventsFromDispatch(IDispatch *pdisp, EventListCallback Callback, LPARAM lparam)
{
IProvideClassInfo* pClassInfo;
pdisp->QueryInterface(IID_IProvideClassInfo, (void **)&pClassInfo);
if (pClassInfo)
{
ITypeInfo *pti;
pClassInfo->GetClassInfo(&pti);
if (!pti) return;
TYPEATTR *pta;
pti->GetTypeAttr(&pta);
for (int i = 0; i < pta->cImplTypes; i++)
{
HREFTYPE href;
ITypeInfo *ptiChild;
TYPEATTR *ptaChild;
int impltype;
pti->GetImplTypeFlags(i, &impltype);
if (impltype & IMPLTYPEFLAG_FSOURCE)
{
pti->GetRefTypeOfImplType(i, &href);
pti->GetRefTypeInfo(href, &ptiChild);
ptiChild->GetTypeAttr(&ptaChild);
for (int l = 0; l < ptaChild->cFuncs; l++)
{
FUNCDESC *pfd;
ptiChild->GetFuncDesc(l, &pfd);
// Get Name
{
BSTR *rgstr = (BSTR *)CoTaskMemAlloc(6 * sizeof(BSTR *));
unsigned int cnames;
/*const HRESULT hr =*/ ptiChild->GetNames(pfd->memid, rgstr, 6, &cnames);
// Add enum string to combo control
char szT[512];
WideCharToMultiByteNull(CP_ACP, 0, rgstr[0], -1, szT, 512, nullptr, nullptr);
(*Callback)(szT, l, pfd->memid, lparam);
for (unsigned int i2 = 0; i2 < cnames; i2++)
{
SysFreeString(rgstr[i2]);
}
CoTaskMemFree(rgstr);
}
ptiChild->ReleaseFuncDesc(pfd);
}
ptiChild->ReleaseTypeAttr(ptaChild);
ptiChild->Release();
}
}
pti->ReleaseTypeAttr(pta);
pti->Release();
pClassInfo->Release();
}
}