2 * IDxDiagContainer Implementation
4 * Copyright 2004 Raphael Junqueira
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "dxdiag_private.h"
24 #include "wine/debug.h"
25 #include "wine/unicode.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag
);
29 /* IDxDiagContainer IUnknown parts follow: */
30 HRESULT WINAPI
IDxDiagContainerImpl_QueryInterface(PDXDIAGCONTAINER iface
, REFIID riid
, LPVOID
*ppobj
)
32 IDxDiagContainerImpl
*This
= (IDxDiagContainerImpl
*)iface
;
34 if (IsEqualGUID(riid
, &IID_IUnknown
)
35 || IsEqualGUID(riid
, &IID_IDxDiagContainer
)) {
36 IDxDiagContainerImpl_AddRef(iface
);
41 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
45 ULONG WINAPI
IDxDiagContainerImpl_AddRef(PDXDIAGCONTAINER iface
) {
46 IDxDiagContainerImpl
*This
= (IDxDiagContainerImpl
*)iface
;
47 ULONG refCount
= InterlockedIncrement(&This
->ref
);
49 TRACE("(%p)->(ref before=%lu)\n", This
, refCount
- 1);
54 ULONG WINAPI
IDxDiagContainerImpl_Release(PDXDIAGCONTAINER iface
) {
55 IDxDiagContainerImpl
*This
= (IDxDiagContainerImpl
*)iface
;
56 ULONG refCount
= InterlockedDecrement(&This
->ref
);
58 TRACE("(%p)->(ref before=%lu)\n", This
, refCount
+ 1);
61 HeapFree(GetProcessHeap(), 0, This
);
66 /* IDxDiagContainer Interface follow: */
67 HRESULT WINAPI
IDxDiagContainerImpl_GetNumberOfChildContainers(PDXDIAGCONTAINER iface
, DWORD
* pdwCount
) {
68 IDxDiagContainerImpl
*This
= (IDxDiagContainerImpl
*)iface
;
69 TRACE("(%p)\n", iface
);
70 if (NULL
== pdwCount
) {
73 *pdwCount
= This
->nSubContainers
;
77 HRESULT WINAPI
IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAINER iface
, DWORD dwIndex
, LPWSTR pwszContainer
, DWORD cchContainer
) {
78 IDxDiagContainerImpl_SubContainer
* p
= NULL
;
80 IDxDiagContainerImpl
*This
= (IDxDiagContainerImpl
*)iface
;
82 TRACE("(%p, %lu, %s, %lu)\n", iface
, dwIndex
, debugstr_w(pwszContainer
), cchContainer
);
84 if (NULL
== pwszContainer
) {
87 if (256 > cchContainer
) {
88 return DXDIAG_E_INSUFFICIENT_BUFFER
;
91 p
= This
->subContainers
;
94 if (cchContainer
<= strlenW(p
->contName
)) {
95 return DXDIAG_E_INSUFFICIENT_BUFFER
;
97 lstrcpynW(pwszContainer
, p
->contName
, cchContainer
);
106 HRESULT WINAPI
IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER iface
, LPCWSTR pwszContainer
, IDxDiagContainer
** ppInstance
) {
107 IDxDiagContainerImpl_SubContainer
* p
= NULL
;
108 IDxDiagContainerImpl
*This
= (IDxDiagContainerImpl
*)iface
;
110 FIXME("(%p, %s, %p)\n", iface
, debugstr_w(pwszContainer
), ppInstance
);
112 if (NULL
== ppInstance
|| NULL
== pwszContainer
) {
116 p
= This
->subContainers
;
118 if (0 == lstrcmpW(p
->contName
, pwszContainer
)) {
119 IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER
)p
, &IID_IDxDiagContainer
, (void**) ppInstance
);
128 HRESULT WINAPI
IDxDiagContainerImpl_GetNumberOfProps(PDXDIAGCONTAINER iface
, DWORD
* pdwCount
) {
129 /* IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; */
130 FIXME("(%p, %p): stub\n", iface
, pdwCount
);
134 HRESULT WINAPI
IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface
, DWORD dwIndex
, LPWSTR pwszPropName
, DWORD cchPropName
) {
135 /* IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; */
136 FIXME("(%p, %lu, %s, %lu): stub\n", iface
, dwIndex
, debugstr_w(pwszPropName
), cchPropName
);
140 HRESULT WINAPI
IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface
, LPCWSTR pwszPropName
, VARIANT
* pvarProp
) {
141 /* IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; */
142 FIXME("(%p, %s, %p): stub\n", iface
, debugstr_w(pwszPropName
), pvarProp
);
147 IDxDiagContainerVtbl DxDiagContainer_Vtbl
=
149 IDxDiagContainerImpl_QueryInterface
,
150 IDxDiagContainerImpl_AddRef
,
151 IDxDiagContainerImpl_Release
,
152 IDxDiagContainerImpl_GetNumberOfChildContainers
,
153 IDxDiagContainerImpl_EnumChildContainerNames
,
154 IDxDiagContainerImpl_GetChildContainer
,
155 IDxDiagContainerImpl_GetNumberOfProps
,
156 IDxDiagContainerImpl_EnumPropNames
,
157 IDxDiagContainerImpl_GetProp
161 HRESULT
DXDiag_CreateDXDiagContainer(REFIID riid
, LPVOID
*ppobj
) {
162 IDxDiagContainerImpl
* container
;
164 TRACE("(%p, %p)\n", debugstr_guid(riid
), ppobj
);
166 container
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDxDiagContainerImpl
));
167 if (NULL
== container
) {
169 return E_OUTOFMEMORY
;
171 container
->lpVtbl
= &DxDiagContainer_Vtbl
;
172 container
->ref
= 0; /* will be inited with QueryInterface */
173 return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER
)container
, riid
, ppobj
);