2 * Copyright 2013 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/debug.h"
32 #include "wine/heap.h"
33 #include "wbemdisp_private.h"
34 #include "wbemdisp_classes.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp
);
40 ISWbemNamedValueSet ISWbemNamedValueSet_iface
;
43 IWbemContext
*context
;
46 static struct namedvalueset
*unsafe_valueset_impl_from_IDispatch(IDispatch
*iface
);
48 static IWbemContext
* unsafe_get_context_from_namedvalueset( IDispatch
*disp
)
50 struct namedvalueset
*valueset
= unsafe_valueset_impl_from_IDispatch( disp
);
51 return valueset
? valueset
->context
: NULL
;
54 static WCHAR
*heap_strdupW( const WCHAR
*src
)
57 if (!src
) return NULL
;
58 if ((dst
= heap_alloc( (lstrlenW( src
) + 1) * sizeof(WCHAR
) ))) lstrcpyW( dst
, src
);
64 static HRESULT
EnumVARIANT_create( struct services
*, IEnumWbemClassObject
*, IEnumVARIANT
** );
65 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
** );
66 static HRESULT
SWbemObject_create( struct services
*, IWbemClassObject
*, ISWbemObject
** );
74 ISWbemPropertySet_tid
,
77 ISWbemNamedValueSet_tid
,
84 static ITypeLib
*wbemdisp_typelib
;
85 static ITypeInfo
*wbemdisp_typeinfo
[last_tid
];
87 static REFIID wbemdisp_tid_id
[] =
93 &IID_ISWbemPropertySet
,
96 &IID_ISWbemNamedValueSet
,
97 &IID_ISWbemNamedValue
,
102 static HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
106 if (!wbemdisp_typelib
)
110 hr
= LoadRegTypeLib( &LIBID_WbemScripting
, 1, 2, LOCALE_SYSTEM_DEFAULT
, &typelib
);
113 ERR( "LoadRegTypeLib failed: %08x\n", hr
);
116 if (InterlockedCompareExchangePointer( (void **)&wbemdisp_typelib
, typelib
, NULL
))
117 ITypeLib_Release( typelib
);
119 if (!wbemdisp_typeinfo
[tid
])
123 hr
= ITypeLib_GetTypeInfoOfGuid( wbemdisp_typelib
, wbemdisp_tid_id
[tid
], &typeinfo
);
126 ERR( "GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(wbemdisp_tid_id
[tid
]), hr
);
129 if (InterlockedCompareExchangePointer( (void **)(wbemdisp_typeinfo
+ tid
), typeinfo
, NULL
))
130 ITypeInfo_Release( typeinfo
);
132 *ret
= wbemdisp_typeinfo
[tid
];
133 ITypeInfo_AddRef( *ret
);
139 ISWbemProperty ISWbemProperty_iface
;
141 IWbemClassObject
*object
;
145 static inline struct property
*impl_from_ISWbemProperty( ISWbemProperty
*iface
)
147 return CONTAINING_RECORD( iface
, struct property
, ISWbemProperty_iface
);
150 static ULONG WINAPI
property_AddRef( ISWbemProperty
*iface
)
152 struct property
*property
= impl_from_ISWbemProperty( iface
);
153 return InterlockedIncrement( &property
->refs
);
156 static ULONG WINAPI
property_Release( ISWbemProperty
*iface
)
158 struct property
*property
= impl_from_ISWbemProperty( iface
);
159 LONG refs
= InterlockedDecrement( &property
->refs
);
162 TRACE( "destroying %p\n", property
);
163 IWbemClassObject_Release( property
->object
);
164 SysFreeString( property
->name
);
165 heap_free( property
);
170 static HRESULT WINAPI
property_QueryInterface( ISWbemProperty
*iface
, REFIID riid
, void **obj
)
172 struct property
*property
= impl_from_ISWbemProperty( iface
);
174 TRACE( "%p %s %p\n", property
, debugstr_guid(riid
), obj
);
176 if (IsEqualGUID( riid
, &IID_ISWbemProperty
) ||
177 IsEqualGUID( riid
, &IID_IDispatch
) ||
178 IsEqualGUID( riid
, &IID_IUnknown
))
184 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
185 return E_NOINTERFACE
;
187 ISWbemProperty_AddRef( iface
);
191 static HRESULT WINAPI
property_GetTypeInfoCount( ISWbemProperty
*iface
, UINT
*count
)
193 struct property
*property
= impl_from_ISWbemProperty( iface
);
194 TRACE( "%p, %p\n", property
, count
);
199 static HRESULT WINAPI
property_GetTypeInfo( ISWbemProperty
*iface
, UINT index
,
200 LCID lcid
, ITypeInfo
**info
)
202 struct property
*property
= impl_from_ISWbemProperty( iface
);
203 TRACE( "%p, %u, %u, %p\n", property
, index
, lcid
, info
);
205 return get_typeinfo( ISWbemProperty_tid
, info
);
208 static HRESULT WINAPI
property_GetIDsOfNames( ISWbemProperty
*iface
, REFIID riid
, LPOLESTR
*names
,
209 UINT count
, LCID lcid
, DISPID
*dispid
)
211 struct property
*property
= impl_from_ISWbemProperty( iface
);
215 TRACE( "%p, %s, %p, %u, %u, %p\n", property
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
217 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
219 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
222 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
223 ITypeInfo_Release( typeinfo
);
228 static HRESULT WINAPI
property_Invoke( ISWbemProperty
*iface
, DISPID member
, REFIID riid
,
229 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
230 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
232 struct property
*property
= impl_from_ISWbemProperty( iface
);
236 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", property
, member
, debugstr_guid(riid
),
237 lcid
, flags
, params
, result
, excep_info
, arg_err
);
239 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
242 hr
= ITypeInfo_Invoke( typeinfo
, &property
->ISWbemProperty_iface
, member
, flags
,
243 params
, result
, excep_info
, arg_err
);
244 ITypeInfo_Release( typeinfo
);
249 static HRESULT WINAPI
property_get_Value( ISWbemProperty
*iface
, VARIANT
*value
)
251 struct property
*property
= impl_from_ISWbemProperty( iface
);
253 TRACE( "%p %p\n", property
, value
);
255 return IWbemClassObject_Get( property
->object
, property
->name
, 0, value
, NULL
, NULL
);
258 static HRESULT WINAPI
property_put_Value( ISWbemProperty
*iface
, VARIANT
*varValue
)
264 static HRESULT WINAPI
property_get_Name( ISWbemProperty
*iface
, BSTR
*strName
)
270 static HRESULT WINAPI
property_get_IsLocal( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsLocal
)
276 static HRESULT WINAPI
property_get_Origin( ISWbemProperty
*iface
, BSTR
*strOrigin
)
282 static HRESULT WINAPI
property_get_CIMType( ISWbemProperty
*iface
, WbemCimtypeEnum
*iCimType
)
288 static HRESULT WINAPI
property_get_Qualifiers_( ISWbemProperty
*iface
, ISWbemQualifierSet
**objWbemQualifierSet
)
294 static HRESULT WINAPI
property_get_IsArray( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsArray
)
300 static const ISWbemPropertyVtbl property_vtbl
=
302 property_QueryInterface
,
305 property_GetTypeInfoCount
,
306 property_GetTypeInfo
,
307 property_GetIDsOfNames
,
312 property_get_IsLocal
,
314 property_get_CIMType
,
315 property_get_Qualifiers_
,
319 static HRESULT
SWbemProperty_create( IWbemClassObject
*wbem_object
, BSTR name
, ISWbemProperty
**obj
)
321 struct property
*property
;
323 TRACE( "%p, %p\n", obj
, wbem_object
);
325 if (!(property
= heap_alloc( sizeof(*property
) ))) return E_OUTOFMEMORY
;
326 property
->ISWbemProperty_iface
.lpVtbl
= &property_vtbl
;
328 property
->object
= wbem_object
;
329 IWbemClassObject_AddRef( property
->object
);
330 property
->name
= SysAllocStringLen( name
, SysStringLen( name
) );
331 *obj
= &property
->ISWbemProperty_iface
;
332 TRACE( "returning iface %p\n", *obj
);
338 ISWbemPropertySet ISWbemPropertySet_iface
;
340 IWbemClassObject
*object
;
343 static inline struct propertyset
*impl_from_ISWbemPropertySet(
344 ISWbemPropertySet
*iface
)
346 return CONTAINING_RECORD( iface
, struct propertyset
, ISWbemPropertySet_iface
);
349 static ULONG WINAPI
propertyset_AddRef( ISWbemPropertySet
*iface
)
351 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
352 return InterlockedIncrement( &propertyset
->refs
);
355 static ULONG WINAPI
propertyset_Release( ISWbemPropertySet
*iface
)
357 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
358 LONG refs
= InterlockedDecrement( &propertyset
->refs
);
361 TRACE( "destroying %p\n", propertyset
);
362 IWbemClassObject_Release( propertyset
->object
);
363 heap_free( propertyset
);
368 static HRESULT WINAPI
propertyset_QueryInterface( ISWbemPropertySet
*iface
,
369 REFIID riid
, void **obj
)
371 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
373 TRACE( "%p %s %p\n", propertyset
, debugstr_guid(riid
), obj
);
375 if (IsEqualGUID( riid
, &IID_ISWbemPropertySet
) ||
376 IsEqualGUID( riid
, &IID_IDispatch
) ||
377 IsEqualGUID( riid
, &IID_IUnknown
))
383 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
384 return E_NOINTERFACE
;
386 ISWbemPropertySet_AddRef( iface
);
390 static HRESULT WINAPI
propertyset_GetTypeInfoCount( ISWbemPropertySet
*iface
, UINT
*count
)
392 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
393 TRACE( "%p, %p\n", propertyset
, count
);
398 static HRESULT WINAPI
propertyset_GetTypeInfo( ISWbemPropertySet
*iface
,
399 UINT index
, LCID lcid
, ITypeInfo
**info
)
401 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
402 TRACE( "%p, %u, %u, %p\n", propertyset
, index
, lcid
, info
);
404 return get_typeinfo( ISWbemPropertySet_tid
, info
);
407 static HRESULT WINAPI
propertyset_GetIDsOfNames( ISWbemPropertySet
*iface
, REFIID riid
, LPOLESTR
*names
,
408 UINT count
, LCID lcid
, DISPID
*dispid
)
410 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
414 TRACE( "%p, %s, %p, %u, %u, %p\n", propertyset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
416 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
418 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
421 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
422 ITypeInfo_Release( typeinfo
);
427 static HRESULT WINAPI
propertyset_Invoke( ISWbemPropertySet
*iface
, DISPID member
, REFIID riid
,
428 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
429 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
431 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
435 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", propertyset
, member
, debugstr_guid(riid
),
436 lcid
, flags
, params
, result
, excep_info
, arg_err
);
438 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
441 hr
= ITypeInfo_Invoke( typeinfo
, &propertyset
->ISWbemPropertySet_iface
, member
, flags
,
442 params
, result
, excep_info
, arg_err
);
443 ITypeInfo_Release( typeinfo
);
448 static HRESULT WINAPI
propertyset_get__NewEnum( ISWbemPropertySet
*iface
, IUnknown
**unk
)
454 static HRESULT WINAPI
propertyset_Item( ISWbemPropertySet
*iface
, BSTR name
,
455 LONG flags
, ISWbemProperty
**prop
)
457 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
461 TRACE( "%p, %s, %08x, %p\n", propertyset
, debugstr_w(name
), flags
, prop
);
463 hr
= IWbemClassObject_Get( propertyset
->object
, name
, 0, &var
, NULL
, NULL
);
466 hr
= SWbemProperty_create( propertyset
->object
, name
, prop
);
467 VariantClear( &var
);
472 static HRESULT WINAPI
propertyset_get_Count( ISWbemPropertySet
*iface
, LONG
*count
)
474 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
478 TRACE( "%p, %p\n", propertyset
, count
);
480 hr
= IWbemClassObject_Get( propertyset
->object
, L
"__PROPERTY_COUNT", 0, &val
, NULL
, NULL
);
483 *count
= V_I4( &val
);
488 static HRESULT WINAPI
propertyset_Add( ISWbemPropertySet
*iface
, BSTR name
, WbemCimtypeEnum type
,
489 VARIANT_BOOL is_array
, LONG flags
, ISWbemProperty
**prop
)
495 static HRESULT WINAPI
propertyset_Remove( ISWbemPropertySet
*iface
, BSTR name
, LONG flags
)
501 static const ISWbemPropertySetVtbl propertyset_vtbl
=
503 propertyset_QueryInterface
,
506 propertyset_GetTypeInfoCount
,
507 propertyset_GetTypeInfo
,
508 propertyset_GetIDsOfNames
,
510 propertyset_get__NewEnum
,
512 propertyset_get_Count
,
517 static HRESULT
SWbemPropertySet_create( IWbemClassObject
*wbem_object
, ISWbemPropertySet
**obj
)
519 struct propertyset
*propertyset
;
521 TRACE( "%p, %p\n", obj
, wbem_object
);
523 if (!(propertyset
= heap_alloc( sizeof(*propertyset
) ))) return E_OUTOFMEMORY
;
524 propertyset
->ISWbemPropertySet_iface
.lpVtbl
= &propertyset_vtbl
;
525 propertyset
->refs
= 1;
526 propertyset
->object
= wbem_object
;
527 IWbemClassObject_AddRef( propertyset
->object
);
528 *obj
= &propertyset
->ISWbemPropertySet_iface
;
530 TRACE( "returning iface %p\n", *obj
);
536 ISWbemServices ISWbemServices_iface
;
538 IWbemServices
*services
;
551 ISWbemObject ISWbemObject_iface
;
553 IWbemClassObject
*object
;
554 struct member
*members
;
557 DISPID last_dispid_method
;
558 struct services
*services
;
563 ISWbemMethodSet ISWbemMethodSet_iface
;
565 struct object
*object
;
570 ISWbemMethod ISWbemMethod_iface
;
572 struct methodset
*set
;
576 static struct method
*impl_from_ISWbemMethod( ISWbemMethod
*iface
)
578 return CONTAINING_RECORD( iface
, struct method
, ISWbemMethod_iface
);
581 static HRESULT WINAPI
method_QueryInterface( ISWbemMethod
*iface
, REFIID riid
, void **ppvObject
)
583 struct method
*method
= impl_from_ISWbemMethod( iface
);
585 TRACE( "%p %s %p\n", method
, debugstr_guid(riid
), ppvObject
);
587 if (IsEqualGUID( riid
, &IID_ISWbemMethod
) ||
588 IsEqualGUID( riid
, &IID_IDispatch
) ||
589 IsEqualGUID( riid
, &IID_IUnknown
))
595 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
596 return E_NOINTERFACE
;
598 ISWbemMethod_AddRef( iface
);
602 static ULONG WINAPI
method_AddRef( ISWbemMethod
*iface
)
604 struct method
*method
= impl_from_ISWbemMethod( iface
);
605 return InterlockedIncrement( &method
->refs
);
608 static ULONG WINAPI
method_Release( ISWbemMethod
*iface
)
610 struct method
*method
= impl_from_ISWbemMethod( iface
);
611 LONG refs
= InterlockedDecrement( &method
->refs
);
614 TRACE( "destroying %p\n", method
);
615 ISWbemMethodSet_Release( &method
->set
->ISWbemMethodSet_iface
);
616 heap_free( method
->name
);
622 static HRESULT WINAPI
method_GetTypeInfoCount(
626 struct method
*method
= impl_from_ISWbemMethod( iface
);
628 TRACE( "%p, %p\n", method
, count
);
633 static HRESULT WINAPI
method_GetTypeInfo(
639 struct method
*method
= impl_from_ISWbemMethod( iface
);
641 TRACE( "%p, %u, %u, %p\n", method
, index
, lcid
, info
);
643 return get_typeinfo( ISWbemMethod_tid
, info
);
646 static HRESULT WINAPI
method_GetIDsOfNames(
654 struct method
*method
= impl_from_ISWbemMethod( iface
);
658 TRACE( "%p, %s, %p, %u, %u, %p\n", method
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
660 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
662 hr
= get_typeinfo( ISWbemMethod_tid
, &typeinfo
);
665 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
666 ITypeInfo_Release( typeinfo
);
671 static HRESULT WINAPI
method_Invoke(
679 EXCEPINFO
*excep_info
,
682 struct method
*method
= impl_from_ISWbemMethod( iface
);
686 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", method
, member
, debugstr_guid(riid
),
687 lcid
, flags
, params
, result
, excep_info
, arg_err
);
689 hr
= get_typeinfo( ISWbemMethod_tid
, &typeinfo
);
692 hr
= ITypeInfo_Invoke( typeinfo
, &method
->ISWbemMethod_iface
, member
, flags
,
693 params
, result
, excep_info
, arg_err
);
694 ITypeInfo_Release( typeinfo
);
699 static HRESULT WINAPI
method_get_Name(
708 static HRESULT WINAPI
method_get_Origin(
717 static HRESULT WINAPI
method_get_InParameters(
719 ISWbemObject
**params
)
721 struct method
*method
= impl_from_ISWbemMethod( iface
);
722 IWbemClassObject
*in_sign
= NULL
, *instance
;
725 TRACE("%p, %p\n", method
, params
);
729 if (SUCCEEDED(hr
= IWbemClassObject_GetMethod( method
->set
->object
->object
,
730 method
->name
, 0, &in_sign
, NULL
)) && in_sign
!= NULL
)
732 hr
= IWbemClassObject_SpawnInstance( in_sign
, 0, &instance
);
733 IWbemClassObject_Release( in_sign
);
736 hr
= SWbemObject_create( method
->set
->object
->services
, instance
, params
);
737 IWbemClassObject_Release( instance
);
744 static HRESULT WINAPI
method_get_OutParameters(
746 ISWbemObject
**params
)
753 static HRESULT WINAPI
method_get_Qualifiers_(
755 ISWbemQualifierSet
**qualifiers
)
762 static const ISWbemMethodVtbl methodvtbl
=
764 method_QueryInterface
,
767 method_GetTypeInfoCount
,
769 method_GetIDsOfNames
,
773 method_get_InParameters
,
774 method_get_OutParameters
,
775 method_get_Qualifiers_
,
778 static HRESULT
SWbemMethod_create( struct methodset
*set
, const WCHAR
*name
, ISWbemMethod
**obj
)
780 struct method
*method
;
782 if (!(method
= heap_alloc(sizeof(*method
))))
783 return E_OUTOFMEMORY
;
785 method
->ISWbemMethod_iface
.lpVtbl
= &methodvtbl
;
788 ISWbemMethodSet_AddRef( &method
->set
->ISWbemMethodSet_iface
);
789 if (!(method
->name
= heap_strdupW( name
)))
791 ISWbemMethod_Release( &method
->ISWbemMethod_iface
);
792 return E_OUTOFMEMORY
;
795 *obj
= &method
->ISWbemMethod_iface
;
800 static struct methodset
*impl_from_ISWbemMethodSet( ISWbemMethodSet
*iface
)
802 return CONTAINING_RECORD( iface
, struct methodset
, ISWbemMethodSet_iface
);
805 static HRESULT WINAPI
methodset_QueryInterface( ISWbemMethodSet
*iface
, REFIID riid
, void **ppvObject
)
807 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
809 TRACE( "%p %s %p\n", set
, debugstr_guid(riid
), ppvObject
);
811 if (IsEqualGUID( riid
, &IID_ISWbemMethodSet
) ||
812 IsEqualGUID( riid
, &IID_IDispatch
) ||
813 IsEqualGUID( riid
, &IID_IUnknown
))
819 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
820 return E_NOINTERFACE
;
822 ISWbemMethodSet_AddRef( iface
);
826 static ULONG WINAPI
methodset_AddRef( ISWbemMethodSet
*iface
)
828 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
829 return InterlockedIncrement( &set
->refs
);
832 static ULONG WINAPI
methodset_Release( ISWbemMethodSet
*iface
)
834 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
835 LONG refs
= InterlockedDecrement( &set
->refs
);
838 TRACE( "destroying %p\n", set
);
839 ISWbemObject_Release( &set
->object
->ISWbemObject_iface
);
845 static HRESULT WINAPI
methodset_GetTypeInfoCount(
846 ISWbemMethodSet
*iface
,
849 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
851 TRACE( "%p, %p\n", set
, count
);
856 static HRESULT WINAPI
methodset_GetTypeInfo( ISWbemMethodSet
*iface
,
861 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
863 TRACE( "%p, %u, %u, %p\n", set
, index
, lcid
, info
);
865 return get_typeinfo( ISWbemMethodSet_tid
, info
);
868 static HRESULT WINAPI
methodset_GetIDsOfNames(
869 ISWbemMethodSet
*iface
,
876 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
880 TRACE( "%p, %s, %p, %u, %u, %p\n", set
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
882 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
884 hr
= get_typeinfo( ISWbemMethodSet_tid
, &typeinfo
);
887 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
888 ITypeInfo_Release( typeinfo
);
893 static HRESULT WINAPI
methodset_Invoke(
894 ISWbemMethodSet
*iface
,
901 EXCEPINFO
*excep_info
,
904 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
908 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
909 lcid
, flags
, params
, result
, excep_info
, arg_err
);
911 hr
= get_typeinfo( ISWbemMethodSet_tid
, &typeinfo
);
914 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemMethodSet_iface
, member
, flags
,
915 params
, result
, excep_info
, arg_err
);
916 ITypeInfo_Release( typeinfo
);
921 static HRESULT WINAPI
methodset_get__NewEnum(
922 ISWbemMethodSet
*iface
,
930 static HRESULT WINAPI
methodset_Item(
931 ISWbemMethodSet
*iface
,
934 ISWbemMethod
**method
)
936 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
937 IWbemClassObject
*in_sign
, *out_sign
;
940 TRACE("%p, %s, %#x, %p\n", set
, debugstr_w(name
), flags
, method
);
944 if (SUCCEEDED(hr
= IWbemClassObject_GetMethod( set
->object
->object
,
945 name
, flags
, &in_sign
, &out_sign
)))
948 IWbemClassObject_Release( in_sign
);
950 IWbemClassObject_Release( out_sign
);
952 return SWbemMethod_create( set
, name
, method
);
958 static HRESULT WINAPI
methodset_get_Count(
959 ISWbemMethodSet
*iface
,
967 static const ISWbemMethodSetVtbl methodsetvtbl
=
969 methodset_QueryInterface
,
972 methodset_GetTypeInfoCount
,
973 methodset_GetTypeInfo
,
974 methodset_GetIDsOfNames
,
976 methodset_get__NewEnum
,
981 static HRESULT
SWbemMethodSet_create( struct object
*object
, ISWbemMethodSet
**obj
)
983 struct methodset
*set
;
985 if (!(set
= heap_alloc(sizeof(*set
))))
986 return E_OUTOFMEMORY
;
988 set
->ISWbemMethodSet_iface
.lpVtbl
= &methodsetvtbl
;
990 set
->object
= object
;
991 ISWbemObject_AddRef( &object
->ISWbemObject_iface
);
993 *obj
= &set
->ISWbemMethodSet_iface
;
998 #define DISPID_BASE 0x1800000
999 #define DISPID_BASE_METHOD 0x1000000
1001 static inline struct object
*impl_from_ISWbemObject(
1002 ISWbemObject
*iface
)
1004 return CONTAINING_RECORD( iface
, struct object
, ISWbemObject_iface
);
1007 static ULONG WINAPI
object_AddRef(
1008 ISWbemObject
*iface
)
1010 struct object
*object
= impl_from_ISWbemObject( iface
);
1011 return InterlockedIncrement( &object
->refs
);
1014 static ULONG WINAPI
object_Release(
1015 ISWbemObject
*iface
)
1017 struct object
*object
= impl_from_ISWbemObject( iface
);
1018 LONG refs
= InterlockedDecrement( &object
->refs
);
1023 TRACE( "destroying %p\n", object
);
1024 IWbemClassObject_Release( object
->object
);
1025 ISWbemServices_Release( &object
->services
->ISWbemServices_iface
);
1026 for (i
= 0; i
< object
->nb_members
; i
++) SysFreeString( object
->members
[i
].name
);
1027 heap_free( object
->members
);
1028 heap_free( object
);
1033 static HRESULT WINAPI
object_QueryInterface(
1034 ISWbemObject
*iface
,
1038 struct object
*object
= impl_from_ISWbemObject( iface
);
1040 TRACE( "%p %s %p\n", object
, debugstr_guid(riid
), ppvObject
);
1042 if (IsEqualGUID( riid
, &IID_ISWbemObject
) ||
1043 IsEqualGUID( riid
, &IID_IDispatch
) ||
1044 IsEqualGUID( riid
, &IID_IUnknown
))
1050 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
1051 return E_NOINTERFACE
;
1053 ISWbemObject_AddRef( iface
);
1057 static HRESULT WINAPI
object_GetTypeInfoCount(
1058 ISWbemObject
*iface
,
1061 struct object
*object
= impl_from_ISWbemObject( iface
);
1063 TRACE( "%p, %p\n", object
, count
);
1068 static HRESULT WINAPI
object_GetTypeInfo(
1069 ISWbemObject
*iface
,
1074 struct object
*object
= impl_from_ISWbemObject( iface
);
1075 FIXME( "%p, %u, %u, %p\n", object
, index
, lcid
, info
);
1079 static BOOL
object_reserve_member( struct object
*object
, unsigned int count
, unsigned int *capacity
)
1081 unsigned int new_capacity
, max_capacity
;
1082 struct member
*new_members
;
1084 if (count
<= *capacity
)
1087 max_capacity
= ~0u / sizeof(*object
->members
);
1088 if (count
> max_capacity
)
1091 new_capacity
= max(4, *capacity
);
1092 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
1094 if (new_capacity
< count
)
1095 new_capacity
= max_capacity
;
1097 if (!(new_members
= heap_realloc( object
->members
, new_capacity
* sizeof(*new_members
) )))
1100 object
->members
= new_members
;
1101 *capacity
= new_capacity
;
1106 static HRESULT
init_members( struct object
*object
)
1108 IWbemClassObject
*sig_in
, *sig_out
;
1109 unsigned int i
, capacity
= 0, count
= 0;
1114 if (object
->members
) return S_OK
;
1116 hr
= IWbemClassObject_BeginEnumeration( object
->object
, 0 );
1117 if (SUCCEEDED( hr
))
1119 while (IWbemClassObject_Next( object
->object
, 0, &name
, NULL
, &type
, NULL
) == S_OK
)
1121 if (!object_reserve_member( object
, count
+ 1, &capacity
)) goto error
;
1122 object
->members
[count
].name
= name
;
1123 object
->members
[count
].is_method
= FALSE
;
1124 object
->members
[count
].dispid
= 0;
1125 object
->members
[count
].type
= type
;
1127 TRACE( "added property %s\n", debugstr_w(name
) );
1129 IWbemClassObject_EndEnumeration( object
->object
);
1132 hr
= IWbemClassObject_BeginMethodEnumeration( object
->object
, 0 );
1133 if (SUCCEEDED( hr
))
1135 while (IWbemClassObject_NextMethod( object
->object
, 0, &name
, &sig_in
, &sig_out
) == S_OK
)
1137 if (!object_reserve_member( object
, count
+ 1, &capacity
)) goto error
;
1138 object
->members
[count
].name
= name
;
1139 object
->members
[count
].is_method
= TRUE
;
1140 object
->members
[count
].dispid
= 0;
1142 if (sig_in
) IWbemClassObject_Release( sig_in
);
1143 if (sig_out
) IWbemClassObject_Release( sig_out
);
1144 TRACE( "added method %s\n", debugstr_w(name
) );
1146 IWbemClassObject_EndMethodEnumeration( object
->object
);
1149 object
->nb_members
= count
;
1150 TRACE( "added %u members\n", object
->nb_members
);
1154 for (i
= 0; i
< count
; ++i
)
1155 SysFreeString( object
->members
[i
].name
);
1156 heap_free( object
->members
);
1157 object
->members
= NULL
;
1158 object
->nb_members
= 0;
1162 static DISPID
get_member_dispid( struct object
*object
, const WCHAR
*name
)
1165 for (i
= 0; i
< object
->nb_members
; i
++)
1167 if (!wcsicmp( object
->members
[i
].name
, name
))
1169 if (!object
->members
[i
].dispid
)
1171 if (object
->members
[i
].is_method
)
1172 object
->members
[i
].dispid
= ++object
->last_dispid_method
;
1174 object
->members
[i
].dispid
= ++object
->last_dispid
;
1176 return object
->members
[i
].dispid
;
1179 return DISPID_UNKNOWN
;
1182 static HRESULT WINAPI
object_GetIDsOfNames(
1183 ISWbemObject
*iface
,
1190 struct object
*object
= impl_from_ISWbemObject( iface
);
1193 ITypeInfo
*typeinfo
;
1195 TRACE( "%p, %s, %p, %u, %u, %p\n", object
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1197 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1199 hr
= init_members( object
);
1200 if (FAILED( hr
)) return hr
;
1202 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
1205 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1206 ITypeInfo_Release( typeinfo
);
1208 if (SUCCEEDED(hr
)) return hr
;
1210 for (i
= 0; i
< count
; i
++)
1212 if ((dispid
[i
] = get_member_dispid( object
, names
[i
] )) == DISPID_UNKNOWN
) break;
1214 if (i
!= count
) return DISP_E_UNKNOWNNAME
;
1218 static BSTR
get_member_name( struct object
*object
, DISPID dispid
, CIMTYPE
*type
)
1221 for (i
= 0; i
< object
->nb_members
; i
++)
1223 if (object
->members
[i
].dispid
== dispid
)
1225 *type
= object
->members
[i
].type
;
1226 return object
->members
[i
].name
;
1232 static VARTYPE
to_vartype( CIMTYPE type
)
1236 case CIM_BOOLEAN
: return VT_BOOL
;
1240 case CIM_DATETIME
: return VT_BSTR
;
1242 case CIM_SINT8
: return VT_I1
;
1243 case CIM_UINT8
: return VT_UI1
;
1244 case CIM_SINT16
: return VT_I2
;
1247 case CIM_SINT32
: return VT_I4
;
1249 case CIM_UINT32
: return VT_UI4
;
1251 case CIM_SINT64
: return VT_I8
;
1252 case CIM_UINT64
: return VT_UI8
;
1254 case CIM_REAL32
: return VT_R4
;
1257 ERR("unhandled type %u\n", type
);
1263 static HRESULT WINAPI
object_Invoke(
1264 ISWbemObject
*iface
,
1271 EXCEPINFO
*excep_info
,
1274 struct object
*object
= impl_from_ISWbemObject( iface
);
1276 ITypeInfo
*typeinfo
;
1282 TRACE( "%p, %x, %s, %u, %x, %p, %p, %p, %p\n", object
, member
, debugstr_guid(riid
),
1283 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1285 if (member
<= DISPID_BASE_METHOD
)
1287 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
1290 hr
= ITypeInfo_Invoke( typeinfo
, &object
->ISWbemObject_iface
, member
, flags
,
1291 params
, result
, excep_info
, arg_err
);
1292 ITypeInfo_Release( typeinfo
);
1297 if (!(name
= get_member_name( object
, member
, &type
)))
1298 return DISP_E_MEMBERNOTFOUND
;
1300 if (flags
== (DISPATCH_METHOD
|DISPATCH_PROPERTYGET
))
1302 memset( params
, 0, sizeof(*params
) );
1303 return IWbemClassObject_Get( object
->object
, name
, 0, result
, NULL
, NULL
);
1305 else if (flags
== DISPATCH_PROPERTYPUT
)
1307 if (!params
->cArgs
|| !params
->rgvarg
)
1309 WARN( "Missing put property value\n" );
1310 return E_INVALIDARG
;
1313 vartype
= to_vartype( type
);
1314 V_VT( &value
) = VT_EMPTY
;
1315 if (SUCCEEDED(hr
= VariantChangeType( &value
, params
->rgvarg
, 0, vartype
)))
1317 hr
= IWbemClassObject_Put( object
->object
, name
, 0, &value
, 0 );
1318 VariantClear( &value
);
1324 FIXME( "flags %x not supported\n", flags
);
1329 static HRESULT WINAPI
object_Put_(
1330 ISWbemObject
*iface
,
1332 IDispatch
*objWbemNamedValueSet
,
1333 ISWbemObjectPath
**objWbemObjectPath
)
1339 static HRESULT WINAPI
object_PutAsync_(
1340 ISWbemObject
*iface
,
1341 IDispatch
*objWbemSink
,
1343 IDispatch
*objWbemNamedValueSet
,
1344 IDispatch
*objWbemAsyncContext
)
1350 static HRESULT WINAPI
object_Delete_(
1351 ISWbemObject
*iface
,
1353 IDispatch
*objWbemNamedValueSet
)
1359 static HRESULT WINAPI
object_DeleteAsync_(
1360 ISWbemObject
*iface
,
1361 IDispatch
*objWbemSink
,
1363 IDispatch
*objWbemNamedValueSet
,
1364 IDispatch
*objWbemAsyncContext
)
1370 static HRESULT WINAPI
object_Instances_(
1371 ISWbemObject
*iface
,
1373 IDispatch
*objWbemNamedValueSet
,
1374 ISWbemObjectSet
**objWbemObjectSet
)
1380 static HRESULT WINAPI
object_InstancesAsync_(
1381 ISWbemObject
*iface
,
1382 IDispatch
*objWbemSink
,
1384 IDispatch
*objWbemNamedValueSet
,
1385 IDispatch
*objWbemAsyncContext
)
1391 static HRESULT WINAPI
object_Subclasses_(
1392 ISWbemObject
*iface
,
1394 IDispatch
*objWbemNamedValueSet
,
1395 ISWbemObjectSet
**objWbemObjectSet
)
1401 static HRESULT WINAPI
object_SubclassesAsync_(
1402 ISWbemObject
*iface
,
1403 IDispatch
*objWbemSink
,
1405 IDispatch
*objWbemNamedValueSet
,
1406 IDispatch
*objWbemAsyncContext
)
1412 static HRESULT WINAPI
object_Associators_(
1413 ISWbemObject
*iface
,
1415 BSTR strResultClass
,
1418 VARIANT_BOOL bClassesOnly
,
1419 VARIANT_BOOL bSchemaOnly
,
1420 BSTR strRequiredAssocQualifier
,
1421 BSTR strRequiredQualifier
,
1423 IDispatch
*objWbemNamedValueSet
,
1424 ISWbemObjectSet
**objWbemObjectSet
)
1430 static HRESULT WINAPI
object_AssociatorsAsync_(
1431 ISWbemObject
*iface
,
1432 IDispatch
*objWbemSink
,
1434 BSTR strResultClass
,
1437 VARIANT_BOOL bClassesOnly
,
1438 VARIANT_BOOL bSchemaOnly
,
1439 BSTR strRequiredAssocQualifier
,
1440 BSTR strRequiredQualifier
,
1442 IDispatch
*objWbemNamedValueSet
,
1443 IDispatch
*objWbemAsyncContext
)
1449 static HRESULT WINAPI
object_References_(
1450 ISWbemObject
*iface
,
1451 BSTR strResultClass
,
1453 VARIANT_BOOL bClassesOnly
,
1454 VARIANT_BOOL bSchemaOnly
,
1455 BSTR strRequiredQualifier
,
1457 IDispatch
*objWbemNamedValueSet
,
1458 ISWbemObjectSet
**objWbemObjectSet
)
1464 static HRESULT WINAPI
object_ReferencesAsync_(
1465 ISWbemObject
*iface
,
1466 IDispatch
*objWbemSink
,
1467 BSTR strResultClass
,
1469 VARIANT_BOOL bClassesOnly
,
1470 VARIANT_BOOL bSchemaOnly
,
1471 BSTR strRequiredQualifier
,
1473 IDispatch
*objWbemNamedValueSet
,
1474 IDispatch
*objWbemAsyncContext
)
1480 static HRESULT WINAPI
object_ExecMethod_(
1481 ISWbemObject
*iface
,
1483 IDispatch
*in_params
,
1485 IDispatch
*valueset
,
1486 ISWbemObject
**out_params
)
1488 struct object
*object
= impl_from_ISWbemObject( iface
);
1492 TRACE( "%p, %s, %p, %#x, %p, %p\n", object
, debugstr_w(method
), in_params
, flags
, valueset
, out_params
);
1494 V_VT( &path
) = VT_EMPTY
;
1495 hr
= IWbemClassObject_Get( object
->object
, L
"__PATH", 0, &path
, NULL
, NULL
);
1498 if (V_VT( &path
) != VT_BSTR
)
1500 WARN( "Unexpected object path value type.\n" );
1501 VariantClear( &path
);
1502 return E_UNEXPECTED
;
1505 hr
= ISWbemServices_ExecMethod( &object
->services
->ISWbemServices_iface
, V_BSTR( &path
), method
,
1506 in_params
, flags
, valueset
, out_params
);
1508 VariantClear( &path
);
1514 static HRESULT WINAPI
object_ExecMethodAsync_(
1515 ISWbemObject
*iface
,
1516 IDispatch
*objWbemSink
,
1518 IDispatch
*objWbemInParameters
,
1520 IDispatch
*objWbemNamedValueSet
,
1521 IDispatch
*objWbemAsyncContext
)
1527 static HRESULT WINAPI
object_Clone_(
1528 ISWbemObject
*iface
,
1529 ISWbemObject
**objWbemObject
)
1535 static HRESULT WINAPI
object_GetObjectText_(
1536 ISWbemObject
*iface
,
1540 struct object
*object
= impl_from_ISWbemObject( iface
);
1542 TRACE( "%p, %#x, %p\n", object
, flags
, text
);
1544 return IWbemClassObject_GetObjectText( object
->object
, flags
, text
);
1547 static HRESULT WINAPI
object_SpawnDerivedClass_(
1548 ISWbemObject
*iface
,
1550 ISWbemObject
**objWbemObject
)
1556 static HRESULT WINAPI
object_SpawnInstance_(
1557 ISWbemObject
*iface
,
1559 ISWbemObject
**objWbemObject
)
1565 static HRESULT WINAPI
object_CompareTo_(
1566 ISWbemObject
*iface
,
1567 IDispatch
*objWbemObject
,
1569 VARIANT_BOOL
*bResult
)
1575 static HRESULT WINAPI
object_get_Qualifiers_(
1576 ISWbemObject
*iface
,
1577 ISWbemQualifierSet
**objWbemQualifierSet
)
1583 static HRESULT WINAPI
object_get_Properties_( ISWbemObject
*iface
, ISWbemPropertySet
**prop_set
)
1585 struct object
*object
= impl_from_ISWbemObject( iface
);
1587 TRACE( "%p, %p\n", object
, prop_set
);
1588 return SWbemPropertySet_create( object
->object
, prop_set
);
1591 static HRESULT WINAPI
object_get_Methods_(
1592 ISWbemObject
*iface
,
1593 ISWbemMethodSet
**set
)
1595 struct object
*object
= impl_from_ISWbemObject( iface
);
1597 TRACE( "%p, %p\n", object
, set
);
1598 return SWbemMethodSet_create( object
, set
);
1601 static HRESULT WINAPI
object_get_Derivation_(
1602 ISWbemObject
*iface
,
1603 VARIANT
*strClassNameArray
)
1609 static HRESULT WINAPI
object_get_Path_(
1610 ISWbemObject
*iface
,
1611 ISWbemObjectPath
**objWbemObjectPath
)
1617 static HRESULT WINAPI
object_get_Security_(
1618 ISWbemObject
*iface
,
1619 ISWbemSecurity
**objWbemSecurity
)
1625 static const ISWbemObjectVtbl object_vtbl
=
1627 object_QueryInterface
,
1630 object_GetTypeInfoCount
,
1632 object_GetIDsOfNames
,
1637 object_DeleteAsync_
,
1639 object_InstancesAsync_
,
1641 object_SubclassesAsync_
,
1642 object_Associators_
,
1643 object_AssociatorsAsync_
,
1645 object_ReferencesAsync_
,
1647 object_ExecMethodAsync_
,
1649 object_GetObjectText_
,
1650 object_SpawnDerivedClass_
,
1651 object_SpawnInstance_
,
1653 object_get_Qualifiers_
,
1654 object_get_Properties_
,
1655 object_get_Methods_
,
1656 object_get_Derivation_
,
1658 object_get_Security_
1661 static struct object
*unsafe_object_impl_from_IDispatch(IDispatch
*iface
)
1665 if (iface
->lpVtbl
!= (IDispatchVtbl
*)&object_vtbl
)
1667 FIXME( "External implementations are not supported.\n" );
1670 return CONTAINING_RECORD(iface
, struct object
, ISWbemObject_iface
);
1673 static HRESULT
SWbemObject_create( struct services
*services
, IWbemClassObject
*wbem_object
,
1674 ISWbemObject
**obj
)
1676 struct object
*object
;
1678 TRACE( "%p, %p\n", obj
, wbem_object
);
1680 if (!(object
= heap_alloc( sizeof(*object
) ))) return E_OUTOFMEMORY
;
1681 object
->ISWbemObject_iface
.lpVtbl
= &object_vtbl
;
1683 object
->object
= wbem_object
;
1684 IWbemClassObject_AddRef( object
->object
);
1685 object
->members
= NULL
;
1686 object
->nb_members
= 0;
1687 object
->last_dispid
= DISPID_BASE
;
1688 object
->last_dispid_method
= DISPID_BASE_METHOD
;
1689 object
->services
= services
;
1690 ISWbemServices_AddRef( &object
->services
->ISWbemServices_iface
);
1692 *obj
= &object
->ISWbemObject_iface
;
1693 TRACE( "returning iface %p\n", *obj
);
1699 ISWbemObjectSet ISWbemObjectSet_iface
;
1701 IEnumWbemClassObject
*objectenum
;
1703 struct services
*services
;
1706 static inline struct objectset
*impl_from_ISWbemObjectSet(
1707 ISWbemObjectSet
*iface
)
1709 return CONTAINING_RECORD( iface
, struct objectset
, ISWbemObjectSet_iface
);
1712 static ULONG WINAPI
objectset_AddRef(
1713 ISWbemObjectSet
*iface
)
1715 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1716 return InterlockedIncrement( &objectset
->refs
);
1719 static ULONG WINAPI
objectset_Release(
1720 ISWbemObjectSet
*iface
)
1722 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1723 LONG refs
= InterlockedDecrement( &objectset
->refs
);
1726 TRACE( "destroying %p\n", objectset
);
1727 IEnumWbemClassObject_Release( objectset
->objectenum
);
1728 ISWbemServices_Release( &objectset
->services
->ISWbemServices_iface
);
1729 heap_free( objectset
);
1734 static HRESULT WINAPI
objectset_QueryInterface(
1735 ISWbemObjectSet
*iface
,
1739 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1741 TRACE( "%p %s %p\n", objectset
, debugstr_guid(riid
), ppvObject
);
1743 if (IsEqualGUID( riid
, &IID_ISWbemObjectSet
) ||
1744 IsEqualGUID( riid
, &IID_IDispatch
) ||
1745 IsEqualGUID( riid
, &IID_IUnknown
))
1751 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
1752 return E_NOINTERFACE
;
1754 ISWbemObjectSet_AddRef( iface
);
1758 static HRESULT WINAPI
objectset_GetTypeInfoCount(
1759 ISWbemObjectSet
*iface
,
1762 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1763 TRACE( "%p, %p\n", objectset
, count
);
1768 static HRESULT WINAPI
objectset_GetTypeInfo(
1769 ISWbemObjectSet
*iface
,
1774 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1775 TRACE( "%p, %u, %u, %p\n", objectset
, index
, lcid
, info
);
1777 return get_typeinfo( ISWbemObjectSet_tid
, info
);
1780 static HRESULT WINAPI
objectset_GetIDsOfNames(
1781 ISWbemObjectSet
*iface
,
1788 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1789 ITypeInfo
*typeinfo
;
1792 TRACE( "%p, %s, %p, %u, %u, %p\n", objectset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1794 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1796 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1799 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1800 ITypeInfo_Release( typeinfo
);
1805 static HRESULT WINAPI
objectset_Invoke(
1806 ISWbemObjectSet
*iface
,
1813 EXCEPINFO
*excep_info
,
1816 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1817 ITypeInfo
*typeinfo
;
1820 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", objectset
, member
, debugstr_guid(riid
),
1821 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1823 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1826 hr
= ITypeInfo_Invoke( typeinfo
, &objectset
->ISWbemObjectSet_iface
, member
, flags
,
1827 params
, result
, excep_info
, arg_err
);
1828 ITypeInfo_Release( typeinfo
);
1833 static HRESULT WINAPI
objectset_get__NewEnum(
1834 ISWbemObjectSet
*iface
,
1837 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1838 IEnumWbemClassObject
*objectenum
;
1841 TRACE( "%p, %p\n", objectset
, pUnk
);
1843 hr
= IEnumWbemClassObject_Clone( objectset
->objectenum
, &objectenum
);
1844 if (FAILED( hr
)) return hr
;
1846 hr
= EnumVARIANT_create( objectset
->services
, objectenum
, (IEnumVARIANT
**)pUnk
);
1847 IEnumWbemClassObject_Release( objectenum
);
1851 static HRESULT WINAPI
objectset_Item(
1852 ISWbemObjectSet
*iface
,
1855 ISWbemObject
**objWbemObject
)
1861 static HRESULT WINAPI
objectset_get_Count(
1862 ISWbemObjectSet
*iface
,
1865 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1867 TRACE( "%p, %p\n", objectset
, iCount
);
1869 *iCount
= objectset
->count
;
1873 static HRESULT WINAPI
objectset_get_Security_(
1874 ISWbemObjectSet
*iface
,
1875 ISWbemSecurity
**objWbemSecurity
)
1881 static HRESULT WINAPI
objectset_ItemIndex(
1882 ISWbemObjectSet
*iface
,
1884 ISWbemObject
**objWbemObject
)
1886 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1889 IEnumVARIANT
*enum_var
;
1892 TRACE( "%p, %d, %p\n", objectset
, lIndex
, objWbemObject
);
1894 *objWbemObject
= NULL
;
1895 hr
= ISWbemObjectSet_get_Count( iface
, &count
);
1896 if (FAILED(hr
)) return hr
;
1898 if (lIndex
>= count
) return WBEM_E_NOT_FOUND
;
1900 hr
= ISWbemObjectSet_get__NewEnum( iface
, (IUnknown
**)&enum_var
);
1901 if (FAILED(hr
)) return hr
;
1903 IEnumVARIANT_Reset( enum_var
);
1904 hr
= IEnumVARIANT_Skip( enum_var
, lIndex
);
1906 hr
= IEnumVARIANT_Next( enum_var
, 1, &var
, NULL
);
1907 IEnumVARIANT_Release( enum_var
);
1911 if (V_VT( &var
) == VT_DISPATCH
)
1912 hr
= IDispatch_QueryInterface( V_DISPATCH( &var
), &IID_ISWbemObject
, (void **)objWbemObject
);
1914 hr
= WBEM_E_NOT_FOUND
;
1915 VariantClear( &var
);
1921 static const ISWbemObjectSetVtbl objectset_vtbl
=
1923 objectset_QueryInterface
,
1926 objectset_GetTypeInfoCount
,
1927 objectset_GetTypeInfo
,
1928 objectset_GetIDsOfNames
,
1930 objectset_get__NewEnum
,
1932 objectset_get_Count
,
1933 objectset_get_Security_
,
1937 static LONG
get_object_count( IEnumWbemClassObject
*iter
)
1940 while (IEnumWbemClassObject_Skip( iter
, WBEM_INFINITE
, 1 ) == S_OK
) count
++;
1941 IEnumWbemClassObject_Reset( iter
);
1945 static HRESULT
SWbemObjectSet_create( struct services
*services
, IEnumWbemClassObject
*wbem_objectenum
,
1946 ISWbemObjectSet
**obj
)
1948 struct objectset
*objectset
;
1950 TRACE( "%p, %p\n", obj
, wbem_objectenum
);
1952 if (!(objectset
= heap_alloc( sizeof(*objectset
) ))) return E_OUTOFMEMORY
;
1953 objectset
->ISWbemObjectSet_iface
.lpVtbl
= &objectset_vtbl
;
1954 objectset
->refs
= 1;
1955 objectset
->objectenum
= wbem_objectenum
;
1956 IEnumWbemClassObject_AddRef( objectset
->objectenum
);
1957 objectset
->count
= get_object_count( objectset
->objectenum
);
1958 objectset
->services
= services
;
1959 ISWbemServices_AddRef( &services
->ISWbemServices_iface
);
1961 *obj
= &objectset
->ISWbemObjectSet_iface
;
1962 TRACE( "returning iface %p\n", *obj
);
1968 IEnumVARIANT IEnumVARIANT_iface
;
1970 IEnumWbemClassObject
*objectenum
;
1971 struct services
*services
;
1974 static inline struct enumvar
*impl_from_IEnumVARIANT(
1975 IEnumVARIANT
*iface
)
1977 return CONTAINING_RECORD( iface
, struct enumvar
, IEnumVARIANT_iface
);
1980 static ULONG WINAPI
enumvar_AddRef(
1981 IEnumVARIANT
*iface
)
1983 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1984 return InterlockedIncrement( &enumvar
->refs
);
1987 static ULONG WINAPI
enumvar_Release(
1988 IEnumVARIANT
*iface
)
1990 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1991 LONG refs
= InterlockedDecrement( &enumvar
->refs
);
1994 TRACE( "destroying %p\n", enumvar
);
1995 IEnumWbemClassObject_Release( enumvar
->objectenum
);
1996 ISWbemServices_Release( &enumvar
->services
->ISWbemServices_iface
);
1997 heap_free( enumvar
);
2002 static HRESULT WINAPI
enumvar_QueryInterface(
2003 IEnumVARIANT
*iface
,
2007 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2009 TRACE( "%p %s %p\n", enumvar
, debugstr_guid(riid
), ppvObject
);
2011 if (IsEqualGUID( riid
, &IID_IEnumVARIANT
) ||
2012 IsEqualGUID( riid
, &IID_IUnknown
))
2018 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2019 return E_NOINTERFACE
;
2021 IEnumVARIANT_AddRef( iface
);
2025 static HRESULT WINAPI
enumvar_Next( IEnumVARIANT
*iface
, ULONG celt
, VARIANT
*var
, ULONG
*fetched
)
2027 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2028 IWbemClassObject
*obj
;
2031 TRACE( "%p, %u, %p, %p\n", iface
, celt
, var
, fetched
);
2033 if (celt
) IEnumWbemClassObject_Next( enumvar
->objectenum
, WBEM_INFINITE
, 1, &obj
, &count
);
2039 hr
= SWbemObject_create( enumvar
->services
, obj
, &sobj
);
2040 IWbemClassObject_Release( obj
);
2041 if (FAILED( hr
)) return hr
;
2043 V_VT( var
) = VT_DISPATCH
;
2044 V_DISPATCH( var
) = (IDispatch
*)sobj
;
2046 if (fetched
) *fetched
= count
;
2047 return (count
< celt
) ? S_FALSE
: S_OK
;
2050 static HRESULT WINAPI
enumvar_Skip( IEnumVARIANT
*iface
, ULONG celt
)
2052 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2054 TRACE( "%p, %u\n", iface
, celt
);
2056 return IEnumWbemClassObject_Skip( enumvar
->objectenum
, WBEM_INFINITE
, celt
);
2059 static HRESULT WINAPI
enumvar_Reset( IEnumVARIANT
*iface
)
2061 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2063 TRACE( "%p\n", iface
);
2065 return IEnumWbemClassObject_Reset( enumvar
->objectenum
);
2068 static HRESULT WINAPI
enumvar_Clone( IEnumVARIANT
*iface
, IEnumVARIANT
**penum
)
2070 FIXME( "%p, %p\n", iface
, penum
);
2074 static const struct IEnumVARIANTVtbl enumvar_vtbl
=
2076 enumvar_QueryInterface
,
2085 static HRESULT
EnumVARIANT_create( struct services
*services
, IEnumWbemClassObject
*objectenum
,
2086 IEnumVARIANT
**obj
)
2088 struct enumvar
*enumvar
;
2090 if (!(enumvar
= heap_alloc( sizeof(*enumvar
) ))) return E_OUTOFMEMORY
;
2091 enumvar
->IEnumVARIANT_iface
.lpVtbl
= &enumvar_vtbl
;
2093 enumvar
->objectenum
= objectenum
;
2094 IEnumWbemClassObject_AddRef( enumvar
->objectenum
);
2095 enumvar
->services
= services
;
2096 ISWbemServices_AddRef( &services
->ISWbemServices_iface
);
2098 *obj
= &enumvar
->IEnumVARIANT_iface
;
2099 TRACE( "returning iface %p\n", *obj
);
2103 static inline struct services
*impl_from_ISWbemServices(
2104 ISWbemServices
*iface
)
2106 return CONTAINING_RECORD( iface
, struct services
, ISWbemServices_iface
);
2109 static ULONG WINAPI
services_AddRef(
2110 ISWbemServices
*iface
)
2112 struct services
*services
= impl_from_ISWbemServices( iface
);
2113 return InterlockedIncrement( &services
->refs
);
2116 static ULONG WINAPI
services_Release(
2117 ISWbemServices
*iface
)
2119 struct services
*services
= impl_from_ISWbemServices( iface
);
2120 LONG refs
= InterlockedDecrement( &services
->refs
);
2123 TRACE( "destroying %p\n", services
);
2124 IWbemServices_Release( services
->services
);
2125 heap_free( services
);
2130 static HRESULT WINAPI
services_QueryInterface(
2131 ISWbemServices
*iface
,
2135 struct services
*services
= impl_from_ISWbemServices( iface
);
2137 TRACE( "%p %s %p\n", services
, debugstr_guid(riid
), ppvObject
);
2139 if (IsEqualGUID( riid
, &IID_ISWbemServices
) ||
2140 IsEqualGUID( riid
, &IID_IDispatch
) ||
2141 IsEqualGUID( riid
, &IID_IUnknown
))
2147 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2148 return E_NOINTERFACE
;
2150 ISWbemServices_AddRef( iface
);
2154 static HRESULT WINAPI
services_GetTypeInfoCount(
2155 ISWbemServices
*iface
,
2158 struct services
*services
= impl_from_ISWbemServices( iface
);
2159 TRACE( "%p, %p\n", services
, count
);
2165 static HRESULT WINAPI
services_GetTypeInfo(
2166 ISWbemServices
*iface
,
2171 struct services
*services
= impl_from_ISWbemServices( iface
);
2172 TRACE( "%p, %u, %u, %p\n", services
, index
, lcid
, info
);
2174 return get_typeinfo( ISWbemServices_tid
, info
);
2177 static HRESULT WINAPI
services_GetIDsOfNames(
2178 ISWbemServices
*iface
,
2185 struct services
*services
= impl_from_ISWbemServices( iface
);
2186 ITypeInfo
*typeinfo
;
2189 TRACE( "%p, %s, %p, %u, %u, %p\n", services
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2191 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2193 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
2196 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2197 ITypeInfo_Release( typeinfo
);
2202 static HRESULT WINAPI
services_Invoke(
2203 ISWbemServices
*iface
,
2210 EXCEPINFO
*excep_info
,
2213 struct services
*services
= impl_from_ISWbemServices( iface
);
2214 ITypeInfo
*typeinfo
;
2217 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", services
, member
, debugstr_guid(riid
),
2218 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2220 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
2223 hr
= ITypeInfo_Invoke( typeinfo
, &services
->ISWbemServices_iface
, member
, flags
,
2224 params
, result
, excep_info
, arg_err
);
2225 ITypeInfo_Release( typeinfo
);
2230 static HRESULT WINAPI
services_Get(
2231 ISWbemServices
*iface
,
2234 IDispatch
*objWbemNamedValueSet
,
2235 ISWbemObject
**objWbemObject
)
2237 struct services
*services
= impl_from_ISWbemServices( iface
);
2238 IWbemClassObject
*obj
;
2241 TRACE( "%p, %s, %d, %p, %p\n", iface
, debugstr_w(strObjectPath
), iFlags
, objWbemNamedValueSet
,
2244 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
2246 hr
= IWbemServices_GetObject( services
->services
, strObjectPath
, iFlags
, NULL
, &obj
, NULL
);
2247 if (hr
!= S_OK
) return hr
;
2249 hr
= SWbemObject_create( services
, obj
, objWbemObject
);
2250 IWbemClassObject_Release( obj
);
2254 static HRESULT WINAPI
services_GetAsync(
2255 ISWbemServices
*iface
,
2256 IDispatch
*objWbemSink
,
2259 IDispatch
*objWbemNamedValueSet
,
2260 IDispatch
*objWbemAsyncContext
)
2266 static HRESULT WINAPI
services_Delete(
2267 ISWbemServices
*iface
,
2270 IDispatch
*objWbemNamedValueSet
)
2276 static HRESULT WINAPI
services_DeleteAsync(
2277 ISWbemServices
* This
,
2278 IDispatch
*objWbemSink
,
2281 IDispatch
*objWbemNamedValueSet
,
2282 IDispatch
*objWbemAsyncContext
)
2288 static BSTR
build_query_string( const WCHAR
*class )
2290 UINT len
= lstrlenW(class) + ARRAY_SIZE(L
"SELECT * FROM ");
2293 if (!(ret
= SysAllocStringLen( NULL
, len
))) return NULL
;
2294 lstrcpyW( ret
, L
"SELECT * FROM " );
2295 lstrcatW( ret
, class );
2299 static HRESULT WINAPI
services_InstancesOf(
2300 ISWbemServices
*iface
,
2303 IDispatch
*objWbemNamedValueSet
,
2304 ISWbemObjectSet
**objWbemObjectSet
)
2306 BSTR query
, wql
= SysAllocString( L
"WQL" );
2309 TRACE( "%p, %s, %x, %p, %p\n", iface
, debugstr_w(strClass
), iFlags
, objWbemNamedValueSet
,
2312 if (!(query
= build_query_string( strClass
)))
2314 SysFreeString( wql
);
2315 return E_OUTOFMEMORY
;
2317 hr
= ISWbemServices_ExecQuery( iface
, query
, wql
, iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
2318 SysFreeString( wql
);
2319 SysFreeString( query
);
2323 static HRESULT WINAPI
services_InstancesOfAsync(
2324 ISWbemServices
*iface
,
2325 IDispatch
*objWbemSink
,
2328 IDispatch
*objWbemNamedValueSet
,
2329 IDispatch
*objWbemAsyncContext
)
2335 static HRESULT WINAPI
services_SubclassesOf(
2336 ISWbemServices
*iface
,
2339 IDispatch
*objWbemNamedValueSet
,
2340 ISWbemObjectSet
**objWbemObjectSet
)
2346 static HRESULT WINAPI
services_SubclassesOfAsync(
2347 ISWbemServices
*iface
,
2348 IDispatch
*objWbemSink
,
2351 IDispatch
*objWbemNamedValueSet
,
2352 IDispatch
*objWbemAsyncContext
)
2358 static HRESULT WINAPI
services_ExecQuery(
2359 ISWbemServices
*iface
,
2361 BSTR strQueryLanguage
,
2363 IDispatch
*objWbemNamedValueSet
,
2364 ISWbemObjectSet
**objWbemObjectSet
)
2366 struct services
*services
= impl_from_ISWbemServices( iface
);
2367 IEnumWbemClassObject
*iter
;
2370 TRACE( "%p, %s, %s, %x, %p, %p\n", iface
, debugstr_w(strQuery
), debugstr_w(strQueryLanguage
),
2371 iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
2373 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
2375 hr
= IWbemServices_ExecQuery( services
->services
, strQueryLanguage
, strQuery
, iFlags
, NULL
, &iter
);
2376 if (hr
!= S_OK
) return hr
;
2378 hr
= SWbemObjectSet_create( services
, iter
, objWbemObjectSet
);
2379 IEnumWbemClassObject_Release( iter
);
2383 static HRESULT WINAPI
services_ExecQueryAsync(
2384 ISWbemServices
*iface
,
2385 IDispatch
*objWbemSink
,
2387 BSTR strQueryLanguage
,
2389 IDispatch
*objWbemNamedValueSet
,
2390 IDispatch
*objWbemAsyncContext
)
2396 static HRESULT WINAPI
services_AssociatorsOf(
2397 ISWbemServices
*iface
,
2400 BSTR strResultClass
,
2403 VARIANT_BOOL bClassesOnly
,
2404 VARIANT_BOOL bSchemaOnly
,
2405 BSTR strRequiredAssocQualifier
,
2406 BSTR strRequiredQualifier
,
2408 IDispatch
*objWbemNamedValueSet
,
2409 ISWbemObjectSet
**objWbemObjectSet
)
2415 static HRESULT WINAPI
services_AssociatorsOfAsync(
2416 ISWbemServices
*iface
,
2417 IDispatch
*objWbemSink
,
2420 BSTR strResultClass
,
2423 VARIANT_BOOL bClassesOnly
,
2424 VARIANT_BOOL bSchemaOnly
,
2425 BSTR strRequiredAssocQualifier
,
2426 BSTR strRequiredQualifier
,
2428 IDispatch
*objWbemNamedValueSet
,
2429 IDispatch
*objWbemAsyncContext
)
2435 static HRESULT WINAPI
services_ReferencesTo(
2436 ISWbemServices
*iface
,
2438 BSTR strResultClass
,
2440 VARIANT_BOOL bClassesOnly
,
2441 VARIANT_BOOL bSchemaOnly
,
2442 BSTR strRequiredQualifier
,
2444 IDispatch
*objWbemNamedValueSet
,
2445 ISWbemObjectSet
**objWbemObjectSet
)
2451 static HRESULT WINAPI
services_ReferencesToAsync(
2452 ISWbemServices
*iface
,
2453 IDispatch
*objWbemSink
,
2455 BSTR strResultClass
,
2457 VARIANT_BOOL bClassesOnly
,
2458 VARIANT_BOOL bSchemaOnly
,
2459 BSTR strRequiredQualifier
,
2461 IDispatch
*objWbemNamedValueSet
,
2462 IDispatch
*objWbemAsyncContext
)
2468 static HRESULT WINAPI
services_ExecNotificationQuery(
2469 ISWbemServices
*iface
,
2471 BSTR strQueryLanguage
,
2473 IDispatch
*objWbemNamedValueSet
,
2474 ISWbemEventSource
**objWbemEventSource
)
2480 static HRESULT WINAPI
services_ExecNotificationQueryAsync(
2481 ISWbemServices
*iface
,
2482 IDispatch
*objWbemSink
,
2484 BSTR strQueryLanguage
,
2486 IDispatch
*objWbemNamedValueSet
,
2487 IDispatch
*objWbemAsyncContext
)
2493 static HRESULT WINAPI
services_ExecMethod(
2494 ISWbemServices
*iface
,
2497 IDispatch
*in_sparams
,
2499 IDispatch
*valueset
,
2500 ISWbemObject
**out_sparams
)
2502 struct services
*services
= impl_from_ISWbemServices( iface
);
2503 IWbemClassObject
*out_params
= NULL
;
2504 struct object
*in_params
;
2505 IWbemContext
*context
;
2508 TRACE( "%p, %s, %s, %p, %#x, %p, %p\n", services
, debugstr_w(path
), debugstr_w(method
), in_sparams
,
2509 flags
, valueset
, out_sparams
);
2511 in_params
= unsafe_object_impl_from_IDispatch( in_sparams
);
2514 context
= unsafe_get_context_from_namedvalueset( valueset
);
2516 hr
= IWbemServices_ExecMethod( services
->services
, path
, method
, flags
, context
, in_params
? in_params
->object
: NULL
,
2517 out_sparams
? &out_params
: NULL
, NULL
);
2519 if (SUCCEEDED(hr
) && out_params
)
2521 hr
= SWbemObject_create( services
, out_params
, out_sparams
);
2522 IWbemClassObject_Release( out_params
);
2528 static HRESULT WINAPI
services_ExecMethodAsync(
2529 ISWbemServices
*iface
,
2530 IDispatch
*objWbemSink
,
2533 IDispatch
*objWbemInParameters
,
2535 IDispatch
*objWbemNamedValueSet
,
2536 IDispatch
*objWbemAsyncContext
)
2542 static HRESULT WINAPI
services_get_Security_(
2543 ISWbemServices
*iface
,
2544 ISWbemSecurity
**objWbemSecurity
)
2546 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
2548 if (!objWbemSecurity
)
2549 return E_INVALIDARG
;
2551 return ISWbemSecurity_create( objWbemSecurity
);
2554 static const ISWbemServicesVtbl services_vtbl
=
2556 services_QueryInterface
,
2559 services_GetTypeInfoCount
,
2560 services_GetTypeInfo
,
2561 services_GetIDsOfNames
,
2566 services_DeleteAsync
,
2567 services_InstancesOf
,
2568 services_InstancesOfAsync
,
2569 services_SubclassesOf
,
2570 services_SubclassesOfAsync
,
2572 services_ExecQueryAsync
,
2573 services_AssociatorsOf
,
2574 services_AssociatorsOfAsync
,
2575 services_ReferencesTo
,
2576 services_ReferencesToAsync
,
2577 services_ExecNotificationQuery
,
2578 services_ExecNotificationQueryAsync
,
2579 services_ExecMethod
,
2580 services_ExecMethodAsync
,
2581 services_get_Security_
2584 static HRESULT
SWbemServices_create( IWbemServices
*wbem_services
, ISWbemServices
**obj
)
2586 struct services
*services
;
2588 TRACE( "%p, %p\n", obj
, wbem_services
);
2590 if (!(services
= heap_alloc( sizeof(*services
) ))) return E_OUTOFMEMORY
;
2591 services
->ISWbemServices_iface
.lpVtbl
= &services_vtbl
;
2593 services
->services
= wbem_services
;
2594 IWbemServices_AddRef( services
->services
);
2596 *obj
= &services
->ISWbemServices_iface
;
2597 TRACE( "returning iface %p\n", *obj
);
2603 ISWbemLocator ISWbemLocator_iface
;
2605 IWbemLocator
*locator
;
2608 static inline struct locator
*impl_from_ISWbemLocator( ISWbemLocator
*iface
)
2610 return CONTAINING_RECORD( iface
, struct locator
, ISWbemLocator_iface
);
2613 static ULONG WINAPI
locator_AddRef(
2614 ISWbemLocator
*iface
)
2616 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2617 return InterlockedIncrement( &locator
->refs
);
2620 static ULONG WINAPI
locator_Release(
2621 ISWbemLocator
*iface
)
2623 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2624 LONG refs
= InterlockedDecrement( &locator
->refs
);
2627 TRACE( "destroying %p\n", locator
);
2628 if (locator
->locator
)
2629 IWbemLocator_Release( locator
->locator
);
2630 heap_free( locator
);
2635 static HRESULT WINAPI
locator_QueryInterface(
2636 ISWbemLocator
*iface
,
2640 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2642 TRACE( "%p, %s, %p\n", locator
, debugstr_guid( riid
), ppvObject
);
2644 if (IsEqualGUID( riid
, &IID_ISWbemLocator
) ||
2645 IsEqualGUID( riid
, &IID_IDispatch
) ||
2646 IsEqualGUID( riid
, &IID_IUnknown
))
2652 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2653 return E_NOINTERFACE
;
2655 ISWbemLocator_AddRef( iface
);
2659 static HRESULT WINAPI
locator_GetTypeInfoCount(
2660 ISWbemLocator
*iface
,
2663 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2665 TRACE( "%p, %p\n", locator
, count
);
2670 static HRESULT WINAPI
locator_GetTypeInfo(
2671 ISWbemLocator
*iface
,
2676 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2677 TRACE( "%p, %u, %u, %p\n", locator
, index
, lcid
, info
);
2679 return get_typeinfo( ISWbemLocator_tid
, info
);
2682 static HRESULT WINAPI
locator_GetIDsOfNames(
2683 ISWbemLocator
*iface
,
2690 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2691 ITypeInfo
*typeinfo
;
2694 TRACE( "%p, %s, %p, %u, %u, %p\n", locator
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2696 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2698 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2701 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2702 ITypeInfo_Release( typeinfo
);
2707 static HRESULT WINAPI
locator_Invoke(
2708 ISWbemLocator
*iface
,
2715 EXCEPINFO
*excep_info
,
2718 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2719 ITypeInfo
*typeinfo
;
2722 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", locator
, member
, debugstr_guid(riid
),
2723 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2725 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2728 hr
= ITypeInfo_Invoke( typeinfo
, &locator
->ISWbemLocator_iface
, member
, flags
,
2729 params
, result
, excep_info
, arg_err
);
2730 ITypeInfo_Release( typeinfo
);
2735 static BSTR
build_resource_string( BSTR server
, BSTR
namespace )
2737 ULONG len
, len_server
= 0, len_namespace
= 0;
2740 if (server
&& *server
) len_server
= lstrlenW( server
);
2741 else len_server
= 1;
2742 if (namespace && *namespace) len_namespace
= lstrlenW( namespace );
2743 else len_namespace
= ARRAY_SIZE(L
"root\\default") - 1;
2745 if (!(ret
= SysAllocStringLen( NULL
, 2 + len_server
+ 1 + len_namespace
))) return NULL
;
2747 ret
[0] = ret
[1] = '\\';
2748 if (server
&& *server
) lstrcpyW( ret
+ 2, server
);
2751 len
= len_server
+ 2;
2754 if (namespace && *namespace) lstrcpyW( ret
+ len
, namespace );
2755 else lstrcpyW( ret
+ len
, L
"root\\default" );
2759 static HRESULT WINAPI
locator_ConnectServer(
2760 ISWbemLocator
*iface
,
2767 LONG iSecurityFlags
,
2768 IDispatch
*objWbemNamedValueSet
,
2769 ISWbemServices
**objWbemServices
)
2771 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2772 IWbemServices
*services
;
2773 IWbemContext
*context
;
2777 TRACE( "%p, %s, %s, %s, %p, %s, %s, 0x%08x, %p, %p\n", iface
, debugstr_w(strServer
),
2778 debugstr_w(strNamespace
), debugstr_w(strUser
), strPassword
, debugstr_w(strLocale
),
2779 debugstr_w(strAuthority
), iSecurityFlags
, objWbemNamedValueSet
, objWbemServices
);
2781 if (!locator
->locator
)
2783 hr
= CoCreateInstance( &CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
,
2784 (void **)&locator
->locator
);
2785 if (hr
!= S_OK
) return hr
;
2788 context
= unsafe_get_context_from_namedvalueset( objWbemNamedValueSet
);
2790 if (!(resource
= build_resource_string( strServer
, strNamespace
))) return E_OUTOFMEMORY
;
2791 hr
= IWbemLocator_ConnectServer( locator
->locator
, resource
, strUser
, strPassword
, strLocale
,
2792 iSecurityFlags
, strAuthority
, context
, &services
);
2793 SysFreeString( resource
);
2794 if (hr
!= S_OK
) return hr
;
2796 hr
= SWbemServices_create( services
, objWbemServices
);
2797 IWbemServices_Release( services
);
2801 static HRESULT WINAPI
locator_get_Security_(
2802 ISWbemLocator
*iface
,
2803 ISWbemSecurity
**objWbemSecurity
)
2805 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
2807 if (!objWbemSecurity
)
2808 return E_INVALIDARG
;
2810 return ISWbemSecurity_create( objWbemSecurity
);
2813 static const ISWbemLocatorVtbl locator_vtbl
=
2815 locator_QueryInterface
,
2818 locator_GetTypeInfoCount
,
2819 locator_GetTypeInfo
,
2820 locator_GetIDsOfNames
,
2822 locator_ConnectServer
,
2823 locator_get_Security_
2826 HRESULT
SWbemLocator_create( void **obj
)
2828 struct locator
*locator
;
2830 TRACE( "%p\n", obj
);
2832 if (!(locator
= heap_alloc( sizeof(*locator
) ))) return E_OUTOFMEMORY
;
2833 locator
->ISWbemLocator_iface
.lpVtbl
= &locator_vtbl
;
2835 locator
->locator
= NULL
;
2837 *obj
= &locator
->ISWbemLocator_iface
;
2838 TRACE( "returning iface %p\n", *obj
);
2844 ISWbemSecurity ISWbemSecurity_iface
;
2846 WbemImpersonationLevelEnum implevel
;
2847 WbemAuthenticationLevelEnum authlevel
;
2850 static inline struct security
*impl_from_ISWbemSecurity( ISWbemSecurity
*iface
)
2852 return CONTAINING_RECORD( iface
, struct security
, ISWbemSecurity_iface
);
2855 static ULONG WINAPI
security_AddRef(
2856 ISWbemSecurity
*iface
)
2858 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2859 return InterlockedIncrement( &security
->refs
);
2862 static ULONG WINAPI
security_Release(
2863 ISWbemSecurity
*iface
)
2865 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2866 LONG refs
= InterlockedDecrement( &security
->refs
);
2869 TRACE( "destroying %p\n", security
);
2870 heap_free( security
);
2875 static HRESULT WINAPI
security_QueryInterface(
2876 ISWbemSecurity
*iface
,
2880 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2881 TRACE( "%p, %s, %p\n", security
, debugstr_guid( riid
), ppvObject
);
2883 if (IsEqualGUID( riid
, &IID_ISWbemSecurity
) ||
2884 IsEqualGUID( riid
, &IID_IDispatch
) ||
2885 IsEqualGUID( riid
, &IID_IUnknown
))
2891 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2892 return E_NOINTERFACE
;
2894 ISWbemSecurity_AddRef( iface
);
2898 static HRESULT WINAPI
security_GetTypeInfoCount(
2899 ISWbemSecurity
*iface
,
2902 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2903 TRACE( "%p, %p\n", security
, count
);
2909 static HRESULT WINAPI
security_GetTypeInfo(
2910 ISWbemSecurity
*iface
,
2915 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2916 TRACE( "%p, %u, %u, %p\n", security
, index
, lcid
, info
);
2918 return get_typeinfo( ISWbemSecurity_tid
, info
);
2921 static HRESULT WINAPI
security_GetIDsOfNames(
2922 ISWbemSecurity
*iface
,
2929 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2930 ITypeInfo
*typeinfo
;
2933 TRACE( "%p, %s, %p, %u, %u, %p\n", security
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2935 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2937 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2940 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2941 ITypeInfo_Release( typeinfo
);
2946 static HRESULT WINAPI
security_Invoke(
2947 ISWbemSecurity
*iface
,
2954 EXCEPINFO
*excep_info
,
2957 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2958 ITypeInfo
*typeinfo
;
2961 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", security
, member
, debugstr_guid(riid
),
2962 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2964 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2967 hr
= ITypeInfo_Invoke( typeinfo
, &security
->ISWbemSecurity_iface
, member
, flags
,
2968 params
, result
, excep_info
, arg_err
);
2969 ITypeInfo_Release( typeinfo
);
2974 static HRESULT WINAPI
security_get_ImpersonationLevel(
2975 ISWbemSecurity
*iface
,
2976 WbemImpersonationLevelEnum
*impersonation_level
)
2978 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2979 FIXME( "%p, %p: stub\n", security
, impersonation_level
);
2981 if (!impersonation_level
)
2982 return E_INVALIDARG
;
2984 *impersonation_level
= security
->implevel
;
2988 static HRESULT WINAPI
security_put_ImpersonationLevel(
2989 ISWbemSecurity
*iface
,
2990 WbemImpersonationLevelEnum impersonation_level
)
2992 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2993 FIXME( "%p, %d: stub\n", security
, impersonation_level
);
2995 security
->implevel
= impersonation_level
;
2999 static HRESULT WINAPI
security_get_AuthenticationLevel(
3000 ISWbemSecurity
*iface
,
3001 WbemAuthenticationLevelEnum
*authentication_level
)
3003 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3004 FIXME( "%p, %p: stub\n", security
, authentication_level
);
3006 if (!authentication_level
)
3007 return E_INVALIDARG
;
3009 *authentication_level
= security
->authlevel
;
3013 static HRESULT WINAPI
security_put_AuthenticationLevel(
3014 ISWbemSecurity
*iface
,
3015 WbemAuthenticationLevelEnum authentication_level
)
3017 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3018 FIXME( "%p, %d: stub\n", security
, authentication_level
);
3020 security
->authlevel
= authentication_level
;
3024 static HRESULT WINAPI
security_get_Privileges(
3025 ISWbemSecurity
*iface
,
3026 ISWbemPrivilegeSet
**privilege_set
)
3028 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3029 FIXME( "%p, %p: stub\n", security
, privilege_set
);
3032 return E_INVALIDARG
;
3037 static const ISWbemSecurityVtbl security_vtbl
=
3039 security_QueryInterface
,
3042 security_GetTypeInfoCount
,
3043 security_GetTypeInfo
,
3044 security_GetIDsOfNames
,
3046 security_get_ImpersonationLevel
,
3047 security_put_ImpersonationLevel
,
3048 security_get_AuthenticationLevel
,
3049 security_put_AuthenticationLevel
,
3050 security_get_Privileges
3053 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
**obj
)
3055 struct security
*security
;
3057 TRACE( "%p\n", obj
);
3059 if (!(security
= heap_alloc( sizeof(*security
) ))) return E_OUTOFMEMORY
;
3060 security
->ISWbemSecurity_iface
.lpVtbl
= &security_vtbl
;
3062 security
->implevel
= wbemImpersonationLevelImpersonate
;
3063 security
->authlevel
= wbemAuthenticationLevelPktPrivacy
;
3065 *obj
= &security
->ISWbemSecurity_iface
;
3066 TRACE( "returning iface %p\n", *obj
);
3072 ISWbemNamedValue ISWbemNamedValue_iface
;
3076 static struct namedvalueset
*impl_from_ISWbemNamedValueSet( ISWbemNamedValueSet
*iface
)
3078 return CONTAINING_RECORD( iface
, struct namedvalueset
, ISWbemNamedValueSet_iface
);
3081 static struct namedvalue
*impl_from_ISWbemNamedValue( ISWbemNamedValue
*iface
)
3083 return CONTAINING_RECORD( iface
, struct namedvalue
, ISWbemNamedValue_iface
);
3086 static HRESULT WINAPI
namedvalue_QueryInterface(
3087 ISWbemNamedValue
*iface
,
3091 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3093 TRACE( "%p, %s, %p\n", value
, debugstr_guid( riid
), ppvObject
);
3095 if (IsEqualGUID( riid
, &IID_ISWbemNamedValue
) ||
3096 IsEqualGUID( riid
, &IID_IDispatch
) ||
3097 IsEqualGUID( riid
, &IID_IUnknown
))
3103 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
3104 return E_NOINTERFACE
;
3106 ISWbemNamedValue_AddRef( iface
);
3110 static ULONG WINAPI
namedvalue_AddRef(
3111 ISWbemNamedValue
*iface
)
3113 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3114 return InterlockedIncrement( &value
->refs
);
3117 static ULONG WINAPI
namedvalue_Release(
3118 ISWbemNamedValue
*iface
)
3120 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3121 LONG refs
= InterlockedDecrement( &value
->refs
);
3124 TRACE( "destroying %p\n", value
);
3130 static HRESULT WINAPI
namedvalue_GetTypeInfoCount(
3131 ISWbemNamedValue
*iface
,
3134 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3135 TRACE( "%p, %p\n", value
, count
);
3141 static HRESULT WINAPI
namedvalue_GetTypeInfo(
3142 ISWbemNamedValue
*iface
,
3147 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3149 TRACE( "%p, %u, %u, %p\n", value
, index
, lcid
, info
);
3151 return get_typeinfo( ISWbemNamedValue_tid
, info
);
3154 static HRESULT WINAPI
namedvalue_GetIDsOfNames(
3155 ISWbemNamedValue
*iface
,
3162 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3163 ITypeInfo
*typeinfo
;
3166 TRACE( "%p, %s, %p, %u, %u, %p\n", value
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3168 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
3170 hr
= get_typeinfo( ISWbemNamedValue_tid
, &typeinfo
);
3173 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
3174 ITypeInfo_Release( typeinfo
);
3179 static HRESULT WINAPI
namedvalue_Invoke(
3180 ISWbemNamedValue
*iface
,
3187 EXCEPINFO
*excep_info
,
3190 struct namedvalue
*set
= impl_from_ISWbemNamedValue( iface
);
3191 ITypeInfo
*typeinfo
;
3194 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
3195 lcid
, flags
, params
, result
, excep_info
, arg_err
);
3197 hr
= get_typeinfo( ISWbemNamedValue_tid
, &typeinfo
);
3200 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemNamedValue_iface
, member
, flags
,
3201 params
, result
, excep_info
, arg_err
);
3202 ITypeInfo_Release( typeinfo
);
3207 static HRESULT WINAPI
namedvalue_get_Value(
3208 ISWbemNamedValue
*iface
,
3216 static HRESULT WINAPI
namedvalue_put_Value(
3217 ISWbemNamedValue
*iface
,
3225 static HRESULT WINAPI
namedvalue_get_Name(
3226 ISWbemNamedValue
*iface
,
3234 static const ISWbemNamedValueVtbl namedvaluevtbl
=
3236 namedvalue_QueryInterface
,
3239 namedvalue_GetTypeInfoCount
,
3240 namedvalue_GetTypeInfo
,
3241 namedvalue_GetIDsOfNames
,
3243 namedvalue_get_Value
,
3244 namedvalue_put_Value
,
3248 static HRESULT
namedvalue_create( ISWbemNamedValue
**value
)
3250 struct namedvalue
*object
;
3252 if (!(object
= heap_alloc(sizeof(*object
))))
3253 return E_OUTOFMEMORY
;
3255 object
->ISWbemNamedValue_iface
.lpVtbl
= &namedvaluevtbl
;
3258 *value
= &object
->ISWbemNamedValue_iface
;
3263 static HRESULT WINAPI
namedvalueset_QueryInterface(
3264 ISWbemNamedValueSet
*iface
,
3268 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3270 TRACE( "%p, %s, %p\n", set
, debugstr_guid( riid
), ppvObject
);
3272 if (IsEqualGUID( riid
, &IID_ISWbemNamedValueSet
) ||
3273 IsEqualGUID( riid
, &IID_IDispatch
) ||
3274 IsEqualGUID( riid
, &IID_IUnknown
))
3280 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
3281 return E_NOINTERFACE
;
3283 ISWbemNamedValueSet_AddRef( iface
);
3287 static ULONG WINAPI
namedvalueset_AddRef(
3288 ISWbemNamedValueSet
*iface
)
3290 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3291 return InterlockedIncrement( &set
->refs
);
3294 static ULONG WINAPI
namedvalueset_Release(
3295 ISWbemNamedValueSet
*iface
)
3297 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3298 LONG refs
= InterlockedDecrement( &set
->refs
);
3301 TRACE( "destroying %p\n", set
);
3303 IWbemContext_Release( set
->context
);
3309 static HRESULT WINAPI
namedvalueset_GetTypeInfoCount(
3310 ISWbemNamedValueSet
*iface
,
3313 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3314 TRACE( "%p, %p\n", set
, count
);
3320 static HRESULT WINAPI
namedvalueset_GetTypeInfo(
3321 ISWbemNamedValueSet
*iface
,
3326 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3328 TRACE( "%p, %u, %u, %p\n", set
, index
, lcid
, info
);
3330 return get_typeinfo( ISWbemNamedValueSet_tid
, info
);
3333 static HRESULT WINAPI
namedvalueset_GetIDsOfNames(
3334 ISWbemNamedValueSet
*iface
,
3341 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3342 ITypeInfo
*typeinfo
;
3345 TRACE( "%p, %s, %p, %u, %u, %p\n", set
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3347 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
3349 hr
= get_typeinfo( ISWbemNamedValueSet_tid
, &typeinfo
);
3352 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
3353 ITypeInfo_Release( typeinfo
);
3358 static HRESULT WINAPI
namedvalueset_Invoke(
3359 ISWbemNamedValueSet
*iface
,
3366 EXCEPINFO
*excep_info
,
3369 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3370 ITypeInfo
*typeinfo
;
3373 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
3374 lcid
, flags
, params
, result
, excep_info
, arg_err
);
3376 hr
= get_typeinfo( ISWbemNamedValueSet_tid
, &typeinfo
);
3379 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemNamedValueSet_iface
, member
, flags
,
3380 params
, result
, excep_info
, arg_err
);
3381 ITypeInfo_Release( typeinfo
);
3386 static HRESULT WINAPI
namedvalueset_get__NewEnum(
3387 ISWbemNamedValueSet
*iface
,
3395 static HRESULT WINAPI
namedvalueset_Item(
3396 ISWbemNamedValueSet
*iface
,
3399 ISWbemNamedValue
**value
)
3401 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3405 TRACE("%p, %s, %#x, %p\n", set
, debugstr_w(name
), flags
, value
);
3407 if (SUCCEEDED(hr
= IWbemContext_GetValue( set
->context
, name
, flags
, &var
)))
3409 VariantClear( &var
);
3410 hr
= namedvalue_create( value
);
3416 static HRESULT WINAPI
namedvalueset_get_Count(
3417 ISWbemNamedValueSet
*iface
,
3425 static HRESULT WINAPI
namedvalueset_Add(
3426 ISWbemNamedValueSet
*iface
,
3430 ISWbemNamedValue
**value
)
3432 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3435 TRACE("%p, %s, %s, %#x, %p\n", set
, debugstr_w(name
), debugstr_variant(var
), flags
, value
);
3437 if (!name
|| !var
|| !value
)
3438 return WBEM_E_INVALID_PARAMETER
;
3440 if (SUCCEEDED(hr
= IWbemContext_SetValue( set
->context
, name
, flags
, var
)))
3442 hr
= namedvalue_create( value
);
3448 static HRESULT WINAPI
namedvalueset_Remove(
3449 ISWbemNamedValueSet
*iface
,
3453 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3455 TRACE("%p, %s, %#x\n", set
, debugstr_w(name
), flags
);
3457 return IWbemContext_DeleteValue( set
->context
, name
, flags
);
3460 static HRESULT WINAPI
namedvalueset_Clone(
3461 ISWbemNamedValueSet
*iface
,
3462 ISWbemNamedValueSet
**valueset
)
3469 static HRESULT WINAPI
namedvalueset_DeleteAll(
3470 ISWbemNamedValueSet
*iface
)
3472 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3476 return IWbemContext_DeleteAll( set
->context
);
3479 static const ISWbemNamedValueSetVtbl namedvalueset_vtbl
=
3481 namedvalueset_QueryInterface
,
3482 namedvalueset_AddRef
,
3483 namedvalueset_Release
,
3484 namedvalueset_GetTypeInfoCount
,
3485 namedvalueset_GetTypeInfo
,
3486 namedvalueset_GetIDsOfNames
,
3487 namedvalueset_Invoke
,
3488 namedvalueset_get__NewEnum
,
3490 namedvalueset_get_Count
,
3492 namedvalueset_Remove
,
3493 namedvalueset_Clone
,
3494 namedvalueset_DeleteAll
,
3497 static struct namedvalueset
*unsafe_valueset_impl_from_IDispatch(IDispatch
*iface
)
3501 if (iface
->lpVtbl
!= (IDispatchVtbl
*)&namedvalueset_vtbl
)
3503 FIXME( "External implementations are not supported.\n" );
3506 return CONTAINING_RECORD(iface
, struct namedvalueset
, ISWbemNamedValueSet_iface
);
3509 HRESULT
SWbemNamedValueSet_create( void **obj
)
3511 struct namedvalueset
*set
;
3514 TRACE( "%p\n", obj
);
3516 if (!(set
= heap_alloc_zero( sizeof(*set
) ))) return E_OUTOFMEMORY
;
3517 set
->ISWbemNamedValueSet_iface
.lpVtbl
= &namedvalueset_vtbl
;
3520 if (FAILED(hr
= CoCreateInstance( &CLSID_WbemContext
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemContext
,
3521 (void **)&set
->context
)))
3523 ISWbemNamedValueSet_Release( &set
->ISWbemNamedValueSet_iface
);
3527 *obj
= &set
->ISWbemNamedValueSet_iface
;
3528 TRACE( "returning iface %p\n", *obj
);