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 "wbemdisp_private.h"
33 #include "wbemdisp_classes.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp
);
39 ISWbemNamedValueSet ISWbemNamedValueSet_iface
;
42 IWbemContext
*context
;
45 static struct namedvalueset
*unsafe_valueset_impl_from_IDispatch(IDispatch
*iface
);
47 static IWbemContext
* unsafe_get_context_from_namedvalueset( IDispatch
*disp
)
49 struct namedvalueset
*valueset
= unsafe_valueset_impl_from_IDispatch( disp
);
50 return valueset
? valueset
->context
: NULL
;
55 static HRESULT
EnumVARIANT_create( struct services
*, IEnumWbemClassObject
*, IEnumVARIANT
** );
56 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
** );
57 static HRESULT
SWbemObject_create( struct services
*, IWbemClassObject
*, ISWbemObject
** );
65 ISWbemPropertySet_tid
,
68 ISWbemNamedValueSet_tid
,
75 static ITypeLib
*wbemdisp_typelib
;
76 static ITypeInfo
*wbemdisp_typeinfo
[last_tid
];
78 static REFIID wbemdisp_tid_id
[] =
84 &IID_ISWbemPropertySet
,
87 &IID_ISWbemNamedValueSet
,
88 &IID_ISWbemNamedValue
,
93 static HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
97 if (!wbemdisp_typelib
)
101 hr
= LoadRegTypeLib( &LIBID_WbemScripting
, 1, 2, LOCALE_SYSTEM_DEFAULT
, &typelib
);
104 ERR( "LoadRegTypeLib failed: %#lx\n", hr
);
107 if (InterlockedCompareExchangePointer( (void **)&wbemdisp_typelib
, typelib
, NULL
))
108 ITypeLib_Release( typelib
);
110 if (!wbemdisp_typeinfo
[tid
])
114 hr
= ITypeLib_GetTypeInfoOfGuid( wbemdisp_typelib
, wbemdisp_tid_id
[tid
], &typeinfo
);
117 ERR( "GetTypeInfoOfGuid(%s) failed: %#lx\n", debugstr_guid(wbemdisp_tid_id
[tid
]), hr
);
120 if (InterlockedCompareExchangePointer( (void **)(wbemdisp_typeinfo
+ tid
), typeinfo
, NULL
))
121 ITypeInfo_Release( typeinfo
);
123 *ret
= wbemdisp_typeinfo
[tid
];
124 ITypeInfo_AddRef( *ret
);
130 ISWbemProperty ISWbemProperty_iface
;
132 IWbemClassObject
*object
;
136 static inline struct property
*impl_from_ISWbemProperty( ISWbemProperty
*iface
)
138 return CONTAINING_RECORD( iface
, struct property
, ISWbemProperty_iface
);
141 static ULONG WINAPI
property_AddRef( ISWbemProperty
*iface
)
143 struct property
*property
= impl_from_ISWbemProperty( iface
);
144 return InterlockedIncrement( &property
->refs
);
147 static ULONG WINAPI
property_Release( ISWbemProperty
*iface
)
149 struct property
*property
= impl_from_ISWbemProperty( iface
);
150 LONG refs
= InterlockedDecrement( &property
->refs
);
153 TRACE( "destroying %p\n", property
);
154 IWbemClassObject_Release( property
->object
);
155 SysFreeString( property
->name
);
161 static HRESULT WINAPI
property_QueryInterface( ISWbemProperty
*iface
, REFIID riid
, void **obj
)
163 struct property
*property
= impl_from_ISWbemProperty( iface
);
165 TRACE( "%p %s %p\n", property
, debugstr_guid(riid
), obj
);
167 if (IsEqualGUID( riid
, &IID_ISWbemProperty
) ||
168 IsEqualGUID( riid
, &IID_IDispatch
) ||
169 IsEqualGUID( riid
, &IID_IUnknown
))
175 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
176 return E_NOINTERFACE
;
178 ISWbemProperty_AddRef( iface
);
182 static HRESULT WINAPI
property_GetTypeInfoCount( ISWbemProperty
*iface
, UINT
*count
)
184 struct property
*property
= impl_from_ISWbemProperty( iface
);
185 TRACE( "%p, %p\n", property
, count
);
190 static HRESULT WINAPI
property_GetTypeInfo( ISWbemProperty
*iface
, UINT index
,
191 LCID lcid
, ITypeInfo
**info
)
193 struct property
*property
= impl_from_ISWbemProperty( iface
);
194 TRACE( "%p, %u, %#lx, %p\n", property
, index
, lcid
, info
);
196 return get_typeinfo( ISWbemProperty_tid
, info
);
199 static HRESULT WINAPI
property_GetIDsOfNames( ISWbemProperty
*iface
, REFIID riid
, LPOLESTR
*names
,
200 UINT count
, LCID lcid
, DISPID
*dispid
)
202 struct property
*property
= impl_from_ISWbemProperty( iface
);
206 TRACE( "%p, %s, %p, %u, %#lx, %p\n", property
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
208 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
210 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
213 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
214 ITypeInfo_Release( typeinfo
);
219 static HRESULT WINAPI
property_Invoke( ISWbemProperty
*iface
, DISPID member
, REFIID riid
,
220 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
221 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
223 struct property
*property
= impl_from_ISWbemProperty( iface
);
227 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", property
, member
, debugstr_guid(riid
),
228 lcid
, flags
, params
, result
, excep_info
, arg_err
);
230 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
233 hr
= ITypeInfo_Invoke( typeinfo
, &property
->ISWbemProperty_iface
, member
, flags
,
234 params
, result
, excep_info
, arg_err
);
235 ITypeInfo_Release( typeinfo
);
240 static HRESULT WINAPI
property_get_Value( ISWbemProperty
*iface
, VARIANT
*value
)
242 struct property
*property
= impl_from_ISWbemProperty( iface
);
244 TRACE( "%p %p\n", property
, value
);
246 return IWbemClassObject_Get( property
->object
, property
->name
, 0, value
, NULL
, NULL
);
249 static HRESULT WINAPI
property_put_Value( ISWbemProperty
*iface
, VARIANT
*varValue
)
255 static HRESULT WINAPI
property_get_Name( ISWbemProperty
*iface
, BSTR
*strName
)
261 static HRESULT WINAPI
property_get_IsLocal( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsLocal
)
267 static HRESULT WINAPI
property_get_Origin( ISWbemProperty
*iface
, BSTR
*strOrigin
)
273 static HRESULT WINAPI
property_get_CIMType( ISWbemProperty
*iface
, WbemCimtypeEnum
*iCimType
)
279 static HRESULT WINAPI
property_get_Qualifiers_( ISWbemProperty
*iface
, ISWbemQualifierSet
**objWbemQualifierSet
)
285 static HRESULT WINAPI
property_get_IsArray( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsArray
)
291 static const ISWbemPropertyVtbl property_vtbl
=
293 property_QueryInterface
,
296 property_GetTypeInfoCount
,
297 property_GetTypeInfo
,
298 property_GetIDsOfNames
,
303 property_get_IsLocal
,
305 property_get_CIMType
,
306 property_get_Qualifiers_
,
310 static HRESULT
SWbemProperty_create( IWbemClassObject
*wbem_object
, BSTR name
, ISWbemProperty
**obj
)
312 struct property
*property
;
314 TRACE( "%p, %p\n", obj
, wbem_object
);
316 if (!(property
= malloc( sizeof(*property
) ))) return E_OUTOFMEMORY
;
317 property
->ISWbemProperty_iface
.lpVtbl
= &property_vtbl
;
319 property
->object
= wbem_object
;
320 IWbemClassObject_AddRef( property
->object
);
321 property
->name
= SysAllocStringLen( name
, SysStringLen( name
) );
322 *obj
= &property
->ISWbemProperty_iface
;
323 TRACE( "returning iface %p\n", *obj
);
329 ISWbemPropertySet ISWbemPropertySet_iface
;
331 IWbemClassObject
*object
;
334 static inline struct propertyset
*impl_from_ISWbemPropertySet(
335 ISWbemPropertySet
*iface
)
337 return CONTAINING_RECORD( iface
, struct propertyset
, ISWbemPropertySet_iface
);
340 static ULONG WINAPI
propertyset_AddRef( ISWbemPropertySet
*iface
)
342 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
343 return InterlockedIncrement( &propertyset
->refs
);
346 static ULONG WINAPI
propertyset_Release( ISWbemPropertySet
*iface
)
348 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
349 LONG refs
= InterlockedDecrement( &propertyset
->refs
);
352 TRACE( "destroying %p\n", propertyset
);
353 IWbemClassObject_Release( propertyset
->object
);
359 static HRESULT WINAPI
propertyset_QueryInterface( ISWbemPropertySet
*iface
,
360 REFIID riid
, void **obj
)
362 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
364 TRACE( "%p %s %p\n", propertyset
, debugstr_guid(riid
), obj
);
366 if (IsEqualGUID( riid
, &IID_ISWbemPropertySet
) ||
367 IsEqualGUID( riid
, &IID_IDispatch
) ||
368 IsEqualGUID( riid
, &IID_IUnknown
))
374 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
375 return E_NOINTERFACE
;
377 ISWbemPropertySet_AddRef( iface
);
381 static HRESULT WINAPI
propertyset_GetTypeInfoCount( ISWbemPropertySet
*iface
, UINT
*count
)
383 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
384 TRACE( "%p, %p\n", propertyset
, count
);
389 static HRESULT WINAPI
propertyset_GetTypeInfo( ISWbemPropertySet
*iface
,
390 UINT index
, LCID lcid
, ITypeInfo
**info
)
392 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
393 TRACE( "%p, %u, %#lx, %p\n", propertyset
, index
, lcid
, info
);
395 return get_typeinfo( ISWbemPropertySet_tid
, info
);
398 static HRESULT WINAPI
propertyset_GetIDsOfNames( ISWbemPropertySet
*iface
, REFIID riid
, LPOLESTR
*names
,
399 UINT count
, LCID lcid
, DISPID
*dispid
)
401 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
405 TRACE( "%p, %s, %p, %u, %#lx, %p\n", propertyset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
407 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
409 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
412 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
413 ITypeInfo_Release( typeinfo
);
418 static HRESULT WINAPI
propertyset_Invoke( ISWbemPropertySet
*iface
, DISPID member
, REFIID riid
,
419 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
420 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
422 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
426 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", propertyset
, member
, debugstr_guid(riid
),
427 lcid
, flags
, params
, result
, excep_info
, arg_err
);
429 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
432 hr
= ITypeInfo_Invoke( typeinfo
, &propertyset
->ISWbemPropertySet_iface
, member
, flags
,
433 params
, result
, excep_info
, arg_err
);
434 ITypeInfo_Release( typeinfo
);
439 static HRESULT WINAPI
propertyset_get__NewEnum( ISWbemPropertySet
*iface
, IUnknown
**unk
)
445 static HRESULT WINAPI
propertyset_Item( ISWbemPropertySet
*iface
, BSTR name
,
446 LONG flags
, ISWbemProperty
**prop
)
448 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
452 TRACE( "%p, %s, %#lx, %p\n", propertyset
, debugstr_w(name
), flags
, prop
);
454 hr
= IWbemClassObject_Get( propertyset
->object
, name
, 0, &var
, NULL
, NULL
);
457 hr
= SWbemProperty_create( propertyset
->object
, name
, prop
);
458 VariantClear( &var
);
463 static HRESULT WINAPI
propertyset_get_Count( ISWbemPropertySet
*iface
, LONG
*count
)
465 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
469 TRACE( "%p, %p\n", propertyset
, count
);
471 hr
= IWbemClassObject_Get( propertyset
->object
, L
"__PROPERTY_COUNT", 0, &val
, NULL
, NULL
);
474 *count
= V_I4( &val
);
479 static HRESULT WINAPI
propertyset_Add( ISWbemPropertySet
*iface
, BSTR name
, WbemCimtypeEnum type
,
480 VARIANT_BOOL is_array
, LONG flags
, ISWbemProperty
**prop
)
486 static HRESULT WINAPI
propertyset_Remove( ISWbemPropertySet
*iface
, BSTR name
, LONG flags
)
492 static const ISWbemPropertySetVtbl propertyset_vtbl
=
494 propertyset_QueryInterface
,
497 propertyset_GetTypeInfoCount
,
498 propertyset_GetTypeInfo
,
499 propertyset_GetIDsOfNames
,
501 propertyset_get__NewEnum
,
503 propertyset_get_Count
,
508 static HRESULT
SWbemPropertySet_create( IWbemClassObject
*wbem_object
, ISWbemPropertySet
**obj
)
510 struct propertyset
*propertyset
;
512 TRACE( "%p, %p\n", obj
, wbem_object
);
514 if (!(propertyset
= malloc( sizeof(*propertyset
) ))) return E_OUTOFMEMORY
;
515 propertyset
->ISWbemPropertySet_iface
.lpVtbl
= &propertyset_vtbl
;
516 propertyset
->refs
= 1;
517 propertyset
->object
= wbem_object
;
518 IWbemClassObject_AddRef( propertyset
->object
);
519 *obj
= &propertyset
->ISWbemPropertySet_iface
;
521 TRACE( "returning iface %p\n", *obj
);
527 ISWbemServices ISWbemServices_iface
;
529 IWbemServices
*services
;
542 ISWbemObject ISWbemObject_iface
;
544 IWbemClassObject
*object
;
545 struct member
*members
;
548 DISPID last_dispid_method
;
549 struct services
*services
;
554 ISWbemMethodSet ISWbemMethodSet_iface
;
556 struct object
*object
;
561 ISWbemMethod ISWbemMethod_iface
;
563 struct methodset
*set
;
567 static struct method
*impl_from_ISWbemMethod( ISWbemMethod
*iface
)
569 return CONTAINING_RECORD( iface
, struct method
, ISWbemMethod_iface
);
572 static HRESULT WINAPI
method_QueryInterface( ISWbemMethod
*iface
, REFIID riid
, void **ppvObject
)
574 struct method
*method
= impl_from_ISWbemMethod( iface
);
576 TRACE( "%p %s %p\n", method
, debugstr_guid(riid
), ppvObject
);
578 if (IsEqualGUID( riid
, &IID_ISWbemMethod
) ||
579 IsEqualGUID( riid
, &IID_IDispatch
) ||
580 IsEqualGUID( riid
, &IID_IUnknown
))
586 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
587 return E_NOINTERFACE
;
589 ISWbemMethod_AddRef( iface
);
593 static ULONG WINAPI
method_AddRef( ISWbemMethod
*iface
)
595 struct method
*method
= impl_from_ISWbemMethod( iface
);
596 return InterlockedIncrement( &method
->refs
);
599 static ULONG WINAPI
method_Release( ISWbemMethod
*iface
)
601 struct method
*method
= impl_from_ISWbemMethod( iface
);
602 LONG refs
= InterlockedDecrement( &method
->refs
);
605 TRACE( "destroying %p\n", method
);
606 ISWbemMethodSet_Release( &method
->set
->ISWbemMethodSet_iface
);
607 free( method
->name
);
613 static HRESULT WINAPI
method_GetTypeInfoCount(
617 struct method
*method
= impl_from_ISWbemMethod( iface
);
619 TRACE( "%p, %p\n", method
, count
);
624 static HRESULT WINAPI
method_GetTypeInfo(
630 struct method
*method
= impl_from_ISWbemMethod( iface
);
632 TRACE( "%p, %u, %#lx, %p\n", method
, index
, lcid
, info
);
634 return get_typeinfo( ISWbemMethod_tid
, info
);
637 static HRESULT WINAPI
method_GetIDsOfNames(
645 struct method
*method
= impl_from_ISWbemMethod( iface
);
649 TRACE( "%p, %s, %p, %u, %#lx, %p\n", method
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
651 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
653 hr
= get_typeinfo( ISWbemMethod_tid
, &typeinfo
);
656 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
657 ITypeInfo_Release( typeinfo
);
662 static HRESULT WINAPI
method_Invoke(
670 EXCEPINFO
*excep_info
,
673 struct method
*method
= impl_from_ISWbemMethod( iface
);
677 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", method
, member
, debugstr_guid(riid
),
678 lcid
, flags
, params
, result
, excep_info
, arg_err
);
680 hr
= get_typeinfo( ISWbemMethod_tid
, &typeinfo
);
683 hr
= ITypeInfo_Invoke( typeinfo
, &method
->ISWbemMethod_iface
, member
, flags
,
684 params
, result
, excep_info
, arg_err
);
685 ITypeInfo_Release( typeinfo
);
690 static HRESULT WINAPI
method_get_Name(
699 static HRESULT WINAPI
method_get_Origin(
708 static HRESULT WINAPI
method_get_InParameters(
710 ISWbemObject
**params
)
712 struct method
*method
= impl_from_ISWbemMethod( iface
);
713 IWbemClassObject
*in_sign
= NULL
, *instance
;
716 TRACE("%p, %p\n", method
, params
);
720 if (SUCCEEDED(hr
= IWbemClassObject_GetMethod( method
->set
->object
->object
,
721 method
->name
, 0, &in_sign
, NULL
)) && in_sign
!= NULL
)
723 hr
= IWbemClassObject_SpawnInstance( in_sign
, 0, &instance
);
724 IWbemClassObject_Release( in_sign
);
727 hr
= SWbemObject_create( method
->set
->object
->services
, instance
, params
);
728 IWbemClassObject_Release( instance
);
735 static HRESULT WINAPI
method_get_OutParameters(
737 ISWbemObject
**params
)
744 static HRESULT WINAPI
method_get_Qualifiers_(
746 ISWbemQualifierSet
**qualifiers
)
753 static const ISWbemMethodVtbl methodvtbl
=
755 method_QueryInterface
,
758 method_GetTypeInfoCount
,
760 method_GetIDsOfNames
,
764 method_get_InParameters
,
765 method_get_OutParameters
,
766 method_get_Qualifiers_
,
769 static HRESULT
SWbemMethod_create( struct methodset
*set
, const WCHAR
*name
, ISWbemMethod
**obj
)
771 struct method
*method
;
773 if (!(method
= malloc( sizeof(*method
) ))) return E_OUTOFMEMORY
;
775 method
->ISWbemMethod_iface
.lpVtbl
= &methodvtbl
;
778 ISWbemMethodSet_AddRef( &method
->set
->ISWbemMethodSet_iface
);
779 if (!(method
->name
= wcsdup( name
)))
781 ISWbemMethod_Release( &method
->ISWbemMethod_iface
);
782 return E_OUTOFMEMORY
;
785 *obj
= &method
->ISWbemMethod_iface
;
790 static struct methodset
*impl_from_ISWbemMethodSet( ISWbemMethodSet
*iface
)
792 return CONTAINING_RECORD( iface
, struct methodset
, ISWbemMethodSet_iface
);
795 static HRESULT WINAPI
methodset_QueryInterface( ISWbemMethodSet
*iface
, REFIID riid
, void **ppvObject
)
797 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
799 TRACE( "%p %s %p\n", set
, debugstr_guid(riid
), ppvObject
);
801 if (IsEqualGUID( riid
, &IID_ISWbemMethodSet
) ||
802 IsEqualGUID( riid
, &IID_IDispatch
) ||
803 IsEqualGUID( riid
, &IID_IUnknown
))
809 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
810 return E_NOINTERFACE
;
812 ISWbemMethodSet_AddRef( iface
);
816 static ULONG WINAPI
methodset_AddRef( ISWbemMethodSet
*iface
)
818 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
819 return InterlockedIncrement( &set
->refs
);
822 static ULONG WINAPI
methodset_Release( ISWbemMethodSet
*iface
)
824 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
825 LONG refs
= InterlockedDecrement( &set
->refs
);
828 TRACE( "destroying %p\n", set
);
829 ISWbemObject_Release( &set
->object
->ISWbemObject_iface
);
835 static HRESULT WINAPI
methodset_GetTypeInfoCount(
836 ISWbemMethodSet
*iface
,
839 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
841 TRACE( "%p, %p\n", set
, count
);
846 static HRESULT WINAPI
methodset_GetTypeInfo( ISWbemMethodSet
*iface
,
851 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
853 TRACE( "%p, %u, %#lx, %p\n", set
, index
, lcid
, info
);
855 return get_typeinfo( ISWbemMethodSet_tid
, info
);
858 static HRESULT WINAPI
methodset_GetIDsOfNames(
859 ISWbemMethodSet
*iface
,
866 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
870 TRACE( "%p, %s, %p, %u, %#lx, %p\n", set
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
872 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
874 hr
= get_typeinfo( ISWbemMethodSet_tid
, &typeinfo
);
877 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
878 ITypeInfo_Release( typeinfo
);
883 static HRESULT WINAPI
methodset_Invoke(
884 ISWbemMethodSet
*iface
,
891 EXCEPINFO
*excep_info
,
894 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
898 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
899 lcid
, flags
, params
, result
, excep_info
, arg_err
);
901 hr
= get_typeinfo( ISWbemMethodSet_tid
, &typeinfo
);
904 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemMethodSet_iface
, member
, flags
,
905 params
, result
, excep_info
, arg_err
);
906 ITypeInfo_Release( typeinfo
);
911 static HRESULT WINAPI
methodset_get__NewEnum(
912 ISWbemMethodSet
*iface
,
920 static HRESULT WINAPI
methodset_Item(
921 ISWbemMethodSet
*iface
,
924 ISWbemMethod
**method
)
926 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
927 IWbemClassObject
*in_sign
, *out_sign
;
930 TRACE("%p, %s, %#lx, %p\n", set
, debugstr_w(name
), flags
, method
);
934 if (SUCCEEDED(hr
= IWbemClassObject_GetMethod( set
->object
->object
,
935 name
, flags
, &in_sign
, &out_sign
)))
938 IWbemClassObject_Release( in_sign
);
940 IWbemClassObject_Release( out_sign
);
942 return SWbemMethod_create( set
, name
, method
);
948 static HRESULT WINAPI
methodset_get_Count(
949 ISWbemMethodSet
*iface
,
957 static const ISWbemMethodSetVtbl methodsetvtbl
=
959 methodset_QueryInterface
,
962 methodset_GetTypeInfoCount
,
963 methodset_GetTypeInfo
,
964 methodset_GetIDsOfNames
,
966 methodset_get__NewEnum
,
971 static HRESULT
SWbemMethodSet_create( struct object
*object
, ISWbemMethodSet
**obj
)
973 struct methodset
*set
;
975 if (!(set
= malloc( sizeof(*set
) ))) return E_OUTOFMEMORY
;
977 set
->ISWbemMethodSet_iface
.lpVtbl
= &methodsetvtbl
;
979 set
->object
= object
;
980 ISWbemObject_AddRef( &object
->ISWbemObject_iface
);
982 *obj
= &set
->ISWbemMethodSet_iface
;
987 #define DISPID_BASE 0x1800000
988 #define DISPID_BASE_METHOD 0x1000000
990 static inline struct object
*impl_from_ISWbemObject(
991 ISWbemObject
*iface
)
993 return CONTAINING_RECORD( iface
, struct object
, ISWbemObject_iface
);
996 static ULONG WINAPI
object_AddRef(
997 ISWbemObject
*iface
)
999 struct object
*object
= impl_from_ISWbemObject( iface
);
1000 return InterlockedIncrement( &object
->refs
);
1003 static ULONG WINAPI
object_Release(
1004 ISWbemObject
*iface
)
1006 struct object
*object
= impl_from_ISWbemObject( iface
);
1007 LONG refs
= InterlockedDecrement( &object
->refs
);
1012 TRACE( "destroying %p\n", object
);
1013 IWbemClassObject_Release( object
->object
);
1014 ISWbemServices_Release( &object
->services
->ISWbemServices_iface
);
1015 for (i
= 0; i
< object
->nb_members
; i
++) SysFreeString( object
->members
[i
].name
);
1016 free( object
->members
);
1022 static HRESULT WINAPI
object_QueryInterface(
1023 ISWbemObject
*iface
,
1027 struct object
*object
= impl_from_ISWbemObject( iface
);
1029 TRACE( "%p %s %p\n", object
, debugstr_guid(riid
), ppvObject
);
1031 if (IsEqualGUID( riid
, &IID_ISWbemObject
) ||
1032 IsEqualGUID( riid
, &IID_IDispatch
) ||
1033 IsEqualGUID( riid
, &IID_IUnknown
))
1039 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
1040 return E_NOINTERFACE
;
1042 ISWbemObject_AddRef( iface
);
1046 static HRESULT WINAPI
object_GetTypeInfoCount(
1047 ISWbemObject
*iface
,
1050 struct object
*object
= impl_from_ISWbemObject( iface
);
1052 TRACE( "%p, %p\n", object
, count
);
1057 static HRESULT WINAPI
object_GetTypeInfo(
1058 ISWbemObject
*iface
,
1063 struct object
*object
= impl_from_ISWbemObject( iface
);
1064 FIXME( "%p, %u, %#lx, %p\n", object
, index
, lcid
, info
);
1068 static BOOL
object_reserve_member( struct object
*object
, unsigned int count
, unsigned int *capacity
)
1070 unsigned int new_capacity
, max_capacity
;
1071 struct member
*new_members
;
1073 if (count
<= *capacity
)
1076 max_capacity
= ~0u / sizeof(*object
->members
);
1077 if (count
> max_capacity
)
1080 new_capacity
= max(4, *capacity
);
1081 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
1083 if (new_capacity
< count
)
1084 new_capacity
= max_capacity
;
1086 if (!(new_members
= realloc( object
->members
, new_capacity
* sizeof(*new_members
) )))
1089 object
->members
= new_members
;
1090 *capacity
= new_capacity
;
1095 static HRESULT
init_members( struct object
*object
)
1097 IWbemClassObject
*sig_in
, *sig_out
;
1098 unsigned int i
, capacity
= 0, count
= 0;
1103 if (object
->members
) return S_OK
;
1105 hr
= IWbemClassObject_BeginEnumeration( object
->object
, 0 );
1106 if (SUCCEEDED( hr
))
1108 while (IWbemClassObject_Next( object
->object
, 0, &name
, NULL
, &type
, NULL
) == S_OK
)
1110 if (!object_reserve_member( object
, count
+ 1, &capacity
)) goto error
;
1111 object
->members
[count
].name
= name
;
1112 object
->members
[count
].is_method
= FALSE
;
1113 object
->members
[count
].dispid
= 0;
1114 object
->members
[count
].type
= type
;
1116 TRACE( "added property %s\n", debugstr_w(name
) );
1118 IWbemClassObject_EndEnumeration( object
->object
);
1121 hr
= IWbemClassObject_BeginMethodEnumeration( object
->object
, 0 );
1122 if (SUCCEEDED( hr
))
1124 while (IWbemClassObject_NextMethod( object
->object
, 0, &name
, &sig_in
, &sig_out
) == S_OK
)
1126 if (!object_reserve_member( object
, count
+ 1, &capacity
)) goto error
;
1127 object
->members
[count
].name
= name
;
1128 object
->members
[count
].is_method
= TRUE
;
1129 object
->members
[count
].dispid
= 0;
1131 if (sig_in
) IWbemClassObject_Release( sig_in
);
1132 if (sig_out
) IWbemClassObject_Release( sig_out
);
1133 TRACE( "added method %s\n", debugstr_w(name
) );
1135 IWbemClassObject_EndMethodEnumeration( object
->object
);
1138 object
->nb_members
= count
;
1139 TRACE( "added %u members\n", object
->nb_members
);
1143 for (i
= 0; i
< count
; ++i
)
1144 SysFreeString( object
->members
[i
].name
);
1145 free( object
->members
);
1146 object
->members
= NULL
;
1147 object
->nb_members
= 0;
1151 static DISPID
get_member_dispid( struct object
*object
, const WCHAR
*name
)
1154 for (i
= 0; i
< object
->nb_members
; i
++)
1156 if (!wcsicmp( object
->members
[i
].name
, name
))
1158 if (!object
->members
[i
].dispid
)
1160 if (object
->members
[i
].is_method
)
1161 object
->members
[i
].dispid
= ++object
->last_dispid_method
;
1163 object
->members
[i
].dispid
= ++object
->last_dispid
;
1165 return object
->members
[i
].dispid
;
1168 return DISPID_UNKNOWN
;
1171 static HRESULT WINAPI
object_GetIDsOfNames(
1172 ISWbemObject
*iface
,
1179 struct object
*object
= impl_from_ISWbemObject( iface
);
1182 ITypeInfo
*typeinfo
;
1184 TRACE( "%p, %s, %p, %u, %#lx, %p\n", object
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1186 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1188 hr
= init_members( object
);
1189 if (FAILED( hr
)) return hr
;
1191 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
1194 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1195 ITypeInfo_Release( typeinfo
);
1197 if (SUCCEEDED(hr
)) return hr
;
1199 for (i
= 0; i
< count
; i
++)
1201 if ((dispid
[i
] = get_member_dispid( object
, names
[i
] )) == DISPID_UNKNOWN
) break;
1203 if (i
!= count
) return DISP_E_UNKNOWNNAME
;
1207 static BSTR
get_member_name( struct object
*object
, DISPID dispid
, CIMTYPE
*type
)
1210 for (i
= 0; i
< object
->nb_members
; i
++)
1212 if (object
->members
[i
].dispid
== dispid
)
1214 *type
= object
->members
[i
].type
;
1215 return object
->members
[i
].name
;
1221 static VARTYPE
to_vartype( CIMTYPE type
)
1225 case CIM_BOOLEAN
: return VT_BOOL
;
1229 case CIM_DATETIME
: return VT_BSTR
;
1231 case CIM_SINT8
: return VT_I1
;
1232 case CIM_UINT8
: return VT_UI1
;
1233 case CIM_SINT16
: return VT_I2
;
1236 case CIM_SINT32
: return VT_I4
;
1238 case CIM_UINT32
: return VT_UI4
;
1240 case CIM_SINT64
: return VT_I8
;
1241 case CIM_UINT64
: return VT_UI8
;
1243 case CIM_REAL32
: return VT_R4
;
1246 ERR( "unhandled type %lu\n", type
);
1252 static HRESULT WINAPI
object_Invoke(
1253 ISWbemObject
*iface
,
1260 EXCEPINFO
*excep_info
,
1263 struct object
*object
= impl_from_ISWbemObject( iface
);
1265 ITypeInfo
*typeinfo
;
1271 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", object
, member
, debugstr_guid(riid
),
1272 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1274 if (member
<= DISPID_BASE_METHOD
)
1276 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
1279 hr
= ITypeInfo_Invoke( typeinfo
, &object
->ISWbemObject_iface
, member
, flags
,
1280 params
, result
, excep_info
, arg_err
);
1281 ITypeInfo_Release( typeinfo
);
1286 if (!(name
= get_member_name( object
, member
, &type
)))
1287 return DISP_E_MEMBERNOTFOUND
;
1289 if (flags
== (DISPATCH_METHOD
|DISPATCH_PROPERTYGET
))
1291 memset( params
, 0, sizeof(*params
) );
1292 return IWbemClassObject_Get( object
->object
, name
, 0, result
, NULL
, NULL
);
1294 else if (flags
== DISPATCH_PROPERTYPUT
)
1296 if (!params
->cArgs
|| !params
->rgvarg
)
1298 WARN( "Missing put property value\n" );
1299 return E_INVALIDARG
;
1302 vartype
= to_vartype( type
);
1303 V_VT( &value
) = VT_EMPTY
;
1304 if (SUCCEEDED(hr
= VariantChangeType( &value
, params
->rgvarg
, 0, vartype
)))
1306 hr
= IWbemClassObject_Put( object
->object
, name
, 0, &value
, 0 );
1307 VariantClear( &value
);
1313 FIXME( "flags %#x not supported\n", flags
);
1318 static HRESULT WINAPI
object_Put_(
1319 ISWbemObject
*iface
,
1321 IDispatch
*objWbemNamedValueSet
,
1322 ISWbemObjectPath
**objWbemObjectPath
)
1328 static HRESULT WINAPI
object_PutAsync_(
1329 ISWbemObject
*iface
,
1330 IDispatch
*objWbemSink
,
1332 IDispatch
*objWbemNamedValueSet
,
1333 IDispatch
*objWbemAsyncContext
)
1339 static HRESULT WINAPI
object_Delete_(
1340 ISWbemObject
*iface
,
1342 IDispatch
*objWbemNamedValueSet
)
1348 static HRESULT WINAPI
object_DeleteAsync_(
1349 ISWbemObject
*iface
,
1350 IDispatch
*objWbemSink
,
1352 IDispatch
*objWbemNamedValueSet
,
1353 IDispatch
*objWbemAsyncContext
)
1359 static HRESULT WINAPI
object_Instances_(
1360 ISWbemObject
*iface
,
1362 IDispatch
*objWbemNamedValueSet
,
1363 ISWbemObjectSet
**objWbemObjectSet
)
1369 static HRESULT WINAPI
object_InstancesAsync_(
1370 ISWbemObject
*iface
,
1371 IDispatch
*objWbemSink
,
1373 IDispatch
*objWbemNamedValueSet
,
1374 IDispatch
*objWbemAsyncContext
)
1380 static HRESULT WINAPI
object_Subclasses_(
1381 ISWbemObject
*iface
,
1383 IDispatch
*objWbemNamedValueSet
,
1384 ISWbemObjectSet
**objWbemObjectSet
)
1390 static HRESULT WINAPI
object_SubclassesAsync_(
1391 ISWbemObject
*iface
,
1392 IDispatch
*objWbemSink
,
1394 IDispatch
*objWbemNamedValueSet
,
1395 IDispatch
*objWbemAsyncContext
)
1401 static HRESULT WINAPI
object_Associators_(
1402 ISWbemObject
*iface
,
1404 BSTR strResultClass
,
1407 VARIANT_BOOL bClassesOnly
,
1408 VARIANT_BOOL bSchemaOnly
,
1409 BSTR strRequiredAssocQualifier
,
1410 BSTR strRequiredQualifier
,
1412 IDispatch
*objWbemNamedValueSet
,
1413 ISWbemObjectSet
**objWbemObjectSet
)
1419 static HRESULT WINAPI
object_AssociatorsAsync_(
1420 ISWbemObject
*iface
,
1421 IDispatch
*objWbemSink
,
1423 BSTR strResultClass
,
1426 VARIANT_BOOL bClassesOnly
,
1427 VARIANT_BOOL bSchemaOnly
,
1428 BSTR strRequiredAssocQualifier
,
1429 BSTR strRequiredQualifier
,
1431 IDispatch
*objWbemNamedValueSet
,
1432 IDispatch
*objWbemAsyncContext
)
1438 static HRESULT WINAPI
object_References_(
1439 ISWbemObject
*iface
,
1440 BSTR strResultClass
,
1442 VARIANT_BOOL bClassesOnly
,
1443 VARIANT_BOOL bSchemaOnly
,
1444 BSTR strRequiredQualifier
,
1446 IDispatch
*objWbemNamedValueSet
,
1447 ISWbemObjectSet
**objWbemObjectSet
)
1453 static HRESULT WINAPI
object_ReferencesAsync_(
1454 ISWbemObject
*iface
,
1455 IDispatch
*objWbemSink
,
1456 BSTR strResultClass
,
1458 VARIANT_BOOL bClassesOnly
,
1459 VARIANT_BOOL bSchemaOnly
,
1460 BSTR strRequiredQualifier
,
1462 IDispatch
*objWbemNamedValueSet
,
1463 IDispatch
*objWbemAsyncContext
)
1469 static HRESULT WINAPI
object_ExecMethod_(
1470 ISWbemObject
*iface
,
1472 IDispatch
*in_params
,
1474 IDispatch
*valueset
,
1475 ISWbemObject
**out_params
)
1477 struct object
*object
= impl_from_ISWbemObject( iface
);
1481 TRACE( "%p, %s, %p, %#lx, %p, %p\n", object
, debugstr_w(method
), in_params
, flags
, valueset
, out_params
);
1483 V_VT( &path
) = VT_EMPTY
;
1484 hr
= IWbemClassObject_Get( object
->object
, L
"__PATH", 0, &path
, NULL
, NULL
);
1487 if (V_VT( &path
) != VT_BSTR
)
1489 WARN( "Unexpected object path value type.\n" );
1490 VariantClear( &path
);
1491 return E_UNEXPECTED
;
1494 hr
= ISWbemServices_ExecMethod( &object
->services
->ISWbemServices_iface
, V_BSTR( &path
), method
,
1495 in_params
, flags
, valueset
, out_params
);
1497 VariantClear( &path
);
1503 static HRESULT WINAPI
object_ExecMethodAsync_(
1504 ISWbemObject
*iface
,
1505 IDispatch
*objWbemSink
,
1507 IDispatch
*objWbemInParameters
,
1509 IDispatch
*objWbemNamedValueSet
,
1510 IDispatch
*objWbemAsyncContext
)
1516 static HRESULT WINAPI
object_Clone_(
1517 ISWbemObject
*iface
,
1518 ISWbemObject
**objWbemObject
)
1524 static HRESULT WINAPI
object_GetObjectText_(
1525 ISWbemObject
*iface
,
1529 struct object
*object
= impl_from_ISWbemObject( iface
);
1531 TRACE( "%p, %#lx, %p\n", object
, flags
, text
);
1533 return IWbemClassObject_GetObjectText( object
->object
, flags
, text
);
1536 static HRESULT WINAPI
object_SpawnDerivedClass_(
1537 ISWbemObject
*iface
,
1539 ISWbemObject
**objWbemObject
)
1545 static HRESULT WINAPI
object_SpawnInstance_(
1546 ISWbemObject
*iface
,
1548 ISWbemObject
**objWbemObject
)
1554 static HRESULT WINAPI
object_CompareTo_(
1555 ISWbemObject
*iface
,
1556 IDispatch
*objWbemObject
,
1558 VARIANT_BOOL
*bResult
)
1564 static HRESULT WINAPI
object_get_Qualifiers_(
1565 ISWbemObject
*iface
,
1566 ISWbemQualifierSet
**objWbemQualifierSet
)
1572 static HRESULT WINAPI
object_get_Properties_( ISWbemObject
*iface
, ISWbemPropertySet
**prop_set
)
1574 struct object
*object
= impl_from_ISWbemObject( iface
);
1576 TRACE( "%p, %p\n", object
, prop_set
);
1577 return SWbemPropertySet_create( object
->object
, prop_set
);
1580 static HRESULT WINAPI
object_get_Methods_(
1581 ISWbemObject
*iface
,
1582 ISWbemMethodSet
**set
)
1584 struct object
*object
= impl_from_ISWbemObject( iface
);
1586 TRACE( "%p, %p\n", object
, set
);
1587 return SWbemMethodSet_create( object
, set
);
1590 static HRESULT WINAPI
object_get_Derivation_(
1591 ISWbemObject
*iface
,
1592 VARIANT
*strClassNameArray
)
1598 static HRESULT WINAPI
object_get_Path_(
1599 ISWbemObject
*iface
,
1600 ISWbemObjectPath
**objWbemObjectPath
)
1606 static HRESULT WINAPI
object_get_Security_(
1607 ISWbemObject
*iface
,
1608 ISWbemSecurity
**objWbemSecurity
)
1614 static const ISWbemObjectVtbl object_vtbl
=
1616 object_QueryInterface
,
1619 object_GetTypeInfoCount
,
1621 object_GetIDsOfNames
,
1626 object_DeleteAsync_
,
1628 object_InstancesAsync_
,
1630 object_SubclassesAsync_
,
1631 object_Associators_
,
1632 object_AssociatorsAsync_
,
1634 object_ReferencesAsync_
,
1636 object_ExecMethodAsync_
,
1638 object_GetObjectText_
,
1639 object_SpawnDerivedClass_
,
1640 object_SpawnInstance_
,
1642 object_get_Qualifiers_
,
1643 object_get_Properties_
,
1644 object_get_Methods_
,
1645 object_get_Derivation_
,
1647 object_get_Security_
1650 static struct object
*unsafe_object_impl_from_IDispatch(IDispatch
*iface
)
1654 if (iface
->lpVtbl
!= (IDispatchVtbl
*)&object_vtbl
)
1656 FIXME( "External implementations are not supported.\n" );
1659 return CONTAINING_RECORD(iface
, struct object
, ISWbemObject_iface
);
1662 static HRESULT
SWbemObject_create( struct services
*services
, IWbemClassObject
*wbem_object
,
1663 ISWbemObject
**obj
)
1665 struct object
*object
;
1667 TRACE( "%p, %p\n", obj
, wbem_object
);
1669 if (!(object
= malloc( sizeof(*object
) ))) return E_OUTOFMEMORY
;
1670 object
->ISWbemObject_iface
.lpVtbl
= &object_vtbl
;
1672 object
->object
= wbem_object
;
1673 IWbemClassObject_AddRef( object
->object
);
1674 object
->members
= NULL
;
1675 object
->nb_members
= 0;
1676 object
->last_dispid
= DISPID_BASE
;
1677 object
->last_dispid_method
= DISPID_BASE_METHOD
;
1678 object
->services
= services
;
1679 ISWbemServices_AddRef( &object
->services
->ISWbemServices_iface
);
1681 *obj
= &object
->ISWbemObject_iface
;
1682 TRACE( "returning iface %p\n", *obj
);
1688 ISWbemObjectSet ISWbemObjectSet_iface
;
1690 IEnumWbemClassObject
*objectenum
;
1692 struct services
*services
;
1695 static inline struct objectset
*impl_from_ISWbemObjectSet(
1696 ISWbemObjectSet
*iface
)
1698 return CONTAINING_RECORD( iface
, struct objectset
, ISWbemObjectSet_iface
);
1701 static ULONG WINAPI
objectset_AddRef(
1702 ISWbemObjectSet
*iface
)
1704 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1705 return InterlockedIncrement( &objectset
->refs
);
1708 static ULONG WINAPI
objectset_Release(
1709 ISWbemObjectSet
*iface
)
1711 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1712 LONG refs
= InterlockedDecrement( &objectset
->refs
);
1715 TRACE( "destroying %p\n", objectset
);
1716 IEnumWbemClassObject_Release( objectset
->objectenum
);
1717 ISWbemServices_Release( &objectset
->services
->ISWbemServices_iface
);
1723 static HRESULT WINAPI
objectset_QueryInterface(
1724 ISWbemObjectSet
*iface
,
1728 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1730 TRACE( "%p %s %p\n", objectset
, debugstr_guid(riid
), ppvObject
);
1732 if (IsEqualGUID( riid
, &IID_ISWbemObjectSet
) ||
1733 IsEqualGUID( riid
, &IID_IDispatch
) ||
1734 IsEqualGUID( riid
, &IID_IUnknown
))
1740 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
1741 return E_NOINTERFACE
;
1743 ISWbemObjectSet_AddRef( iface
);
1747 static HRESULT WINAPI
objectset_GetTypeInfoCount(
1748 ISWbemObjectSet
*iface
,
1751 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1752 TRACE( "%p, %p\n", objectset
, count
);
1757 static HRESULT WINAPI
objectset_GetTypeInfo(
1758 ISWbemObjectSet
*iface
,
1763 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1764 TRACE( "%p, %u, %#lx, %p\n", objectset
, index
, lcid
, info
);
1766 return get_typeinfo( ISWbemObjectSet_tid
, info
);
1769 static HRESULT WINAPI
objectset_GetIDsOfNames(
1770 ISWbemObjectSet
*iface
,
1777 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1778 ITypeInfo
*typeinfo
;
1781 TRACE( "%p, %s, %p, %u, %#lx, %p\n", objectset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1783 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1785 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1788 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1789 ITypeInfo_Release( typeinfo
);
1794 static HRESULT WINAPI
objectset_Invoke(
1795 ISWbemObjectSet
*iface
,
1802 EXCEPINFO
*excep_info
,
1805 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1806 ITypeInfo
*typeinfo
;
1809 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", objectset
, member
, debugstr_guid(riid
),
1810 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1812 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1815 hr
= ITypeInfo_Invoke( typeinfo
, &objectset
->ISWbemObjectSet_iface
, member
, flags
,
1816 params
, result
, excep_info
, arg_err
);
1817 ITypeInfo_Release( typeinfo
);
1822 static HRESULT WINAPI
objectset_get__NewEnum(
1823 ISWbemObjectSet
*iface
,
1826 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1827 IEnumWbemClassObject
*objectenum
;
1830 TRACE( "%p, %p\n", objectset
, pUnk
);
1832 hr
= IEnumWbemClassObject_Clone( objectset
->objectenum
, &objectenum
);
1833 if (FAILED( hr
)) return hr
;
1835 hr
= EnumVARIANT_create( objectset
->services
, objectenum
, (IEnumVARIANT
**)pUnk
);
1836 IEnumWbemClassObject_Release( objectenum
);
1840 static HRESULT WINAPI
objectset_Item(
1841 ISWbemObjectSet
*iface
,
1844 ISWbemObject
**objWbemObject
)
1850 static HRESULT WINAPI
objectset_get_Count(
1851 ISWbemObjectSet
*iface
,
1854 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1856 TRACE( "%p, %p\n", objectset
, iCount
);
1858 *iCount
= objectset
->count
;
1862 static HRESULT WINAPI
objectset_get_Security_(
1863 ISWbemObjectSet
*iface
,
1864 ISWbemSecurity
**objWbemSecurity
)
1870 static HRESULT WINAPI
objectset_ItemIndex(
1871 ISWbemObjectSet
*iface
,
1873 ISWbemObject
**objWbemObject
)
1875 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1878 IEnumVARIANT
*enum_var
;
1881 TRACE( "%p, %ld, %p\n", objectset
, lIndex
, objWbemObject
);
1883 *objWbemObject
= NULL
;
1884 hr
= ISWbemObjectSet_get_Count( iface
, &count
);
1885 if (FAILED(hr
)) return hr
;
1887 if (lIndex
>= count
) return WBEM_E_NOT_FOUND
;
1889 hr
= ISWbemObjectSet_get__NewEnum( iface
, (IUnknown
**)&enum_var
);
1890 if (FAILED(hr
)) return hr
;
1892 IEnumVARIANT_Reset( enum_var
);
1893 hr
= IEnumVARIANT_Skip( enum_var
, lIndex
);
1895 hr
= IEnumVARIANT_Next( enum_var
, 1, &var
, NULL
);
1896 IEnumVARIANT_Release( enum_var
);
1900 if (V_VT( &var
) == VT_DISPATCH
)
1901 hr
= IDispatch_QueryInterface( V_DISPATCH( &var
), &IID_ISWbemObject
, (void **)objWbemObject
);
1903 hr
= WBEM_E_NOT_FOUND
;
1904 VariantClear( &var
);
1910 static const ISWbemObjectSetVtbl objectset_vtbl
=
1912 objectset_QueryInterface
,
1915 objectset_GetTypeInfoCount
,
1916 objectset_GetTypeInfo
,
1917 objectset_GetIDsOfNames
,
1919 objectset_get__NewEnum
,
1921 objectset_get_Count
,
1922 objectset_get_Security_
,
1926 static LONG
get_object_count( IEnumWbemClassObject
*iter
)
1929 while (IEnumWbemClassObject_Skip( iter
, WBEM_INFINITE
, 1 ) == S_OK
) count
++;
1930 IEnumWbemClassObject_Reset( iter
);
1934 static HRESULT
SWbemObjectSet_create( struct services
*services
, IEnumWbemClassObject
*wbem_objectenum
,
1935 ISWbemObjectSet
**obj
)
1937 struct objectset
*objectset
;
1939 TRACE( "%p, %p\n", obj
, wbem_objectenum
);
1941 if (!(objectset
= malloc( sizeof(*objectset
) ))) return E_OUTOFMEMORY
;
1942 objectset
->ISWbemObjectSet_iface
.lpVtbl
= &objectset_vtbl
;
1943 objectset
->refs
= 1;
1944 objectset
->objectenum
= wbem_objectenum
;
1945 IEnumWbemClassObject_AddRef( objectset
->objectenum
);
1946 objectset
->count
= get_object_count( objectset
->objectenum
);
1947 objectset
->services
= services
;
1948 ISWbemServices_AddRef( &services
->ISWbemServices_iface
);
1950 *obj
= &objectset
->ISWbemObjectSet_iface
;
1951 TRACE( "returning iface %p\n", *obj
);
1957 IEnumVARIANT IEnumVARIANT_iface
;
1959 IEnumWbemClassObject
*objectenum
;
1960 struct services
*services
;
1963 static inline struct enumvar
*impl_from_IEnumVARIANT(
1964 IEnumVARIANT
*iface
)
1966 return CONTAINING_RECORD( iface
, struct enumvar
, IEnumVARIANT_iface
);
1969 static ULONG WINAPI
enumvar_AddRef(
1970 IEnumVARIANT
*iface
)
1972 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1973 return InterlockedIncrement( &enumvar
->refs
);
1976 static ULONG WINAPI
enumvar_Release(
1977 IEnumVARIANT
*iface
)
1979 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1980 LONG refs
= InterlockedDecrement( &enumvar
->refs
);
1983 TRACE( "destroying %p\n", enumvar
);
1984 IEnumWbemClassObject_Release( enumvar
->objectenum
);
1985 ISWbemServices_Release( &enumvar
->services
->ISWbemServices_iface
);
1991 static HRESULT WINAPI
enumvar_QueryInterface(
1992 IEnumVARIANT
*iface
,
1996 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1998 TRACE( "%p %s %p\n", enumvar
, debugstr_guid(riid
), ppvObject
);
2000 if (IsEqualGUID( riid
, &IID_IEnumVARIANT
) ||
2001 IsEqualGUID( riid
, &IID_IUnknown
))
2007 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2008 return E_NOINTERFACE
;
2010 IEnumVARIANT_AddRef( iface
);
2014 static HRESULT WINAPI
enumvar_Next( IEnumVARIANT
*iface
, ULONG celt
, VARIANT
*var
, ULONG
*fetched
)
2016 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2017 IWbemClassObject
*obj
;
2020 TRACE( "%p, %lu, %p, %p\n", iface
, celt
, var
, fetched
);
2022 if (celt
) IEnumWbemClassObject_Next( enumvar
->objectenum
, WBEM_INFINITE
, 1, &obj
, &count
);
2028 hr
= SWbemObject_create( enumvar
->services
, obj
, &sobj
);
2029 IWbemClassObject_Release( obj
);
2030 if (FAILED( hr
)) return hr
;
2032 V_VT( var
) = VT_DISPATCH
;
2033 V_DISPATCH( var
) = (IDispatch
*)sobj
;
2035 if (fetched
) *fetched
= count
;
2036 return (count
< celt
) ? S_FALSE
: S_OK
;
2039 static HRESULT WINAPI
enumvar_Skip( IEnumVARIANT
*iface
, ULONG celt
)
2041 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2043 TRACE( "%p, %lu\n", iface
, celt
);
2045 return IEnumWbemClassObject_Skip( enumvar
->objectenum
, WBEM_INFINITE
, celt
);
2048 static HRESULT WINAPI
enumvar_Reset( IEnumVARIANT
*iface
)
2050 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2052 TRACE( "%p\n", iface
);
2054 return IEnumWbemClassObject_Reset( enumvar
->objectenum
);
2057 static HRESULT WINAPI
enumvar_Clone( IEnumVARIANT
*iface
, IEnumVARIANT
**penum
)
2059 FIXME( "%p, %p\n", iface
, penum
);
2063 static const struct IEnumVARIANTVtbl enumvar_vtbl
=
2065 enumvar_QueryInterface
,
2074 static HRESULT
EnumVARIANT_create( struct services
*services
, IEnumWbemClassObject
*objectenum
,
2075 IEnumVARIANT
**obj
)
2077 struct enumvar
*enumvar
;
2079 if (!(enumvar
= malloc( sizeof(*enumvar
) ))) return E_OUTOFMEMORY
;
2080 enumvar
->IEnumVARIANT_iface
.lpVtbl
= &enumvar_vtbl
;
2082 enumvar
->objectenum
= objectenum
;
2083 IEnumWbemClassObject_AddRef( enumvar
->objectenum
);
2084 enumvar
->services
= services
;
2085 ISWbemServices_AddRef( &services
->ISWbemServices_iface
);
2087 *obj
= &enumvar
->IEnumVARIANT_iface
;
2088 TRACE( "returning iface %p\n", *obj
);
2092 static inline struct services
*impl_from_ISWbemServices(
2093 ISWbemServices
*iface
)
2095 return CONTAINING_RECORD( iface
, struct services
, ISWbemServices_iface
);
2098 static ULONG WINAPI
services_AddRef(
2099 ISWbemServices
*iface
)
2101 struct services
*services
= impl_from_ISWbemServices( iface
);
2102 return InterlockedIncrement( &services
->refs
);
2105 static ULONG WINAPI
services_Release(
2106 ISWbemServices
*iface
)
2108 struct services
*services
= impl_from_ISWbemServices( iface
);
2109 LONG refs
= InterlockedDecrement( &services
->refs
);
2112 TRACE( "destroying %p\n", services
);
2113 IWbemServices_Release( services
->services
);
2119 static HRESULT WINAPI
services_QueryInterface(
2120 ISWbemServices
*iface
,
2124 struct services
*services
= impl_from_ISWbemServices( iface
);
2126 TRACE( "%p %s %p\n", services
, debugstr_guid(riid
), ppvObject
);
2128 if (IsEqualGUID( riid
, &IID_ISWbemServices
) ||
2129 IsEqualGUID( riid
, &IID_IDispatch
) ||
2130 IsEqualGUID( riid
, &IID_IUnknown
))
2136 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2137 return E_NOINTERFACE
;
2139 ISWbemServices_AddRef( iface
);
2143 static HRESULT WINAPI
services_GetTypeInfoCount(
2144 ISWbemServices
*iface
,
2147 struct services
*services
= impl_from_ISWbemServices( iface
);
2148 TRACE( "%p, %p\n", services
, count
);
2154 static HRESULT WINAPI
services_GetTypeInfo(
2155 ISWbemServices
*iface
,
2160 struct services
*services
= impl_from_ISWbemServices( iface
);
2161 TRACE( "%p, %u, %#lx, %p\n", services
, index
, lcid
, info
);
2163 return get_typeinfo( ISWbemServices_tid
, info
);
2166 static HRESULT WINAPI
services_GetIDsOfNames(
2167 ISWbemServices
*iface
,
2174 struct services
*services
= impl_from_ISWbemServices( iface
);
2175 ITypeInfo
*typeinfo
;
2178 TRACE( "%p, %s, %p, %u, %#lx, %p\n", services
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2180 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2182 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
2185 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2186 ITypeInfo_Release( typeinfo
);
2191 static HRESULT WINAPI
services_Invoke(
2192 ISWbemServices
*iface
,
2199 EXCEPINFO
*excep_info
,
2202 struct services
*services
= impl_from_ISWbemServices( iface
);
2203 ITypeInfo
*typeinfo
;
2206 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", services
, member
, debugstr_guid(riid
),
2207 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2209 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
2212 hr
= ITypeInfo_Invoke( typeinfo
, &services
->ISWbemServices_iface
, member
, flags
,
2213 params
, result
, excep_info
, arg_err
);
2214 ITypeInfo_Release( typeinfo
);
2219 static HRESULT WINAPI
services_Get(
2220 ISWbemServices
*iface
,
2223 IDispatch
*objWbemNamedValueSet
,
2224 ISWbemObject
**objWbemObject
)
2226 struct services
*services
= impl_from_ISWbemServices( iface
);
2227 IWbemClassObject
*obj
;
2230 TRACE( "%p, %s, %#lx, %p, %p\n", iface
, debugstr_w(strObjectPath
), iFlags
, objWbemNamedValueSet
,
2233 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
2235 hr
= IWbemServices_GetObject( services
->services
, strObjectPath
, iFlags
, NULL
, &obj
, NULL
);
2236 if (hr
!= S_OK
) return hr
;
2238 hr
= SWbemObject_create( services
, obj
, objWbemObject
);
2239 IWbemClassObject_Release( obj
);
2243 static HRESULT WINAPI
services_GetAsync(
2244 ISWbemServices
*iface
,
2245 IDispatch
*objWbemSink
,
2248 IDispatch
*objWbemNamedValueSet
,
2249 IDispatch
*objWbemAsyncContext
)
2255 static HRESULT WINAPI
services_Delete(
2256 ISWbemServices
*iface
,
2259 IDispatch
*objWbemNamedValueSet
)
2265 static HRESULT WINAPI
services_DeleteAsync(
2266 ISWbemServices
* This
,
2267 IDispatch
*objWbemSink
,
2270 IDispatch
*objWbemNamedValueSet
,
2271 IDispatch
*objWbemAsyncContext
)
2277 static BSTR
build_query_string( const WCHAR
*class )
2279 UINT len
= lstrlenW(class) + ARRAY_SIZE(L
"SELECT * FROM ");
2282 if (!(ret
= SysAllocStringLen( NULL
, len
))) return NULL
;
2283 lstrcpyW( ret
, L
"SELECT * FROM " );
2284 lstrcatW( ret
, class );
2288 static HRESULT WINAPI
services_InstancesOf(
2289 ISWbemServices
*iface
,
2292 IDispatch
*objWbemNamedValueSet
,
2293 ISWbemObjectSet
**objWbemObjectSet
)
2295 BSTR query
, wql
= SysAllocString( L
"WQL" );
2298 TRACE( "%p, %s, %#lx, %p, %p\n", iface
, debugstr_w(strClass
), iFlags
, objWbemNamedValueSet
,
2301 if (!(query
= build_query_string( strClass
)))
2303 SysFreeString( wql
);
2304 return E_OUTOFMEMORY
;
2306 hr
= ISWbemServices_ExecQuery( iface
, query
, wql
, iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
2307 SysFreeString( wql
);
2308 SysFreeString( query
);
2312 static HRESULT WINAPI
services_InstancesOfAsync(
2313 ISWbemServices
*iface
,
2314 IDispatch
*objWbemSink
,
2317 IDispatch
*objWbemNamedValueSet
,
2318 IDispatch
*objWbemAsyncContext
)
2324 static HRESULT WINAPI
services_SubclassesOf(
2325 ISWbemServices
*iface
,
2328 IDispatch
*objWbemNamedValueSet
,
2329 ISWbemObjectSet
**objWbemObjectSet
)
2335 static HRESULT WINAPI
services_SubclassesOfAsync(
2336 ISWbemServices
*iface
,
2337 IDispatch
*objWbemSink
,
2340 IDispatch
*objWbemNamedValueSet
,
2341 IDispatch
*objWbemAsyncContext
)
2347 static HRESULT WINAPI
services_ExecQuery(
2348 ISWbemServices
*iface
,
2350 BSTR strQueryLanguage
,
2352 IDispatch
*objWbemNamedValueSet
,
2353 ISWbemObjectSet
**objWbemObjectSet
)
2355 struct services
*services
= impl_from_ISWbemServices( iface
);
2356 IEnumWbemClassObject
*iter
;
2359 TRACE( "%p, %s, %s, %#lx, %p, %p\n", iface
, debugstr_w(strQuery
), debugstr_w(strQueryLanguage
),
2360 iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
2362 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
2364 hr
= IWbemServices_ExecQuery( services
->services
, strQueryLanguage
, strQuery
, iFlags
, NULL
, &iter
);
2365 if (hr
!= S_OK
) return hr
;
2367 hr
= SWbemObjectSet_create( services
, iter
, objWbemObjectSet
);
2368 IEnumWbemClassObject_Release( iter
);
2372 static HRESULT WINAPI
services_ExecQueryAsync(
2373 ISWbemServices
*iface
,
2374 IDispatch
*objWbemSink
,
2376 BSTR strQueryLanguage
,
2378 IDispatch
*objWbemNamedValueSet
,
2379 IDispatch
*objWbemAsyncContext
)
2385 static HRESULT WINAPI
services_AssociatorsOf(
2386 ISWbemServices
*iface
,
2389 BSTR strResultClass
,
2392 VARIANT_BOOL bClassesOnly
,
2393 VARIANT_BOOL bSchemaOnly
,
2394 BSTR strRequiredAssocQualifier
,
2395 BSTR strRequiredQualifier
,
2397 IDispatch
*objWbemNamedValueSet
,
2398 ISWbemObjectSet
**objWbemObjectSet
)
2404 static HRESULT WINAPI
services_AssociatorsOfAsync(
2405 ISWbemServices
*iface
,
2406 IDispatch
*objWbemSink
,
2409 BSTR strResultClass
,
2412 VARIANT_BOOL bClassesOnly
,
2413 VARIANT_BOOL bSchemaOnly
,
2414 BSTR strRequiredAssocQualifier
,
2415 BSTR strRequiredQualifier
,
2417 IDispatch
*objWbemNamedValueSet
,
2418 IDispatch
*objWbemAsyncContext
)
2424 static HRESULT WINAPI
services_ReferencesTo(
2425 ISWbemServices
*iface
,
2427 BSTR strResultClass
,
2429 VARIANT_BOOL bClassesOnly
,
2430 VARIANT_BOOL bSchemaOnly
,
2431 BSTR strRequiredQualifier
,
2433 IDispatch
*objWbemNamedValueSet
,
2434 ISWbemObjectSet
**objWbemObjectSet
)
2440 static HRESULT WINAPI
services_ReferencesToAsync(
2441 ISWbemServices
*iface
,
2442 IDispatch
*objWbemSink
,
2444 BSTR strResultClass
,
2446 VARIANT_BOOL bClassesOnly
,
2447 VARIANT_BOOL bSchemaOnly
,
2448 BSTR strRequiredQualifier
,
2450 IDispatch
*objWbemNamedValueSet
,
2451 IDispatch
*objWbemAsyncContext
)
2457 static HRESULT WINAPI
services_ExecNotificationQuery(
2458 ISWbemServices
*iface
,
2460 BSTR strQueryLanguage
,
2462 IDispatch
*objWbemNamedValueSet
,
2463 ISWbemEventSource
**objWbemEventSource
)
2469 static HRESULT WINAPI
services_ExecNotificationQueryAsync(
2470 ISWbemServices
*iface
,
2471 IDispatch
*objWbemSink
,
2473 BSTR strQueryLanguage
,
2475 IDispatch
*objWbemNamedValueSet
,
2476 IDispatch
*objWbemAsyncContext
)
2482 static HRESULT WINAPI
services_ExecMethod(
2483 ISWbemServices
*iface
,
2486 IDispatch
*in_sparams
,
2488 IDispatch
*valueset
,
2489 ISWbemObject
**out_sparams
)
2491 struct services
*services
= impl_from_ISWbemServices( iface
);
2492 IWbemClassObject
*out_params
= NULL
;
2493 struct object
*in_params
;
2494 IWbemContext
*context
;
2497 TRACE( "%p, %s, %s, %p, %#lx, %p, %p\n", services
, debugstr_w(path
), debugstr_w(method
), in_sparams
,
2498 flags
, valueset
, out_sparams
);
2500 in_params
= unsafe_object_impl_from_IDispatch( in_sparams
);
2503 context
= unsafe_get_context_from_namedvalueset( valueset
);
2505 hr
= IWbemServices_ExecMethod( services
->services
, path
, method
, flags
, context
, in_params
? in_params
->object
: NULL
,
2506 out_sparams
? &out_params
: NULL
, NULL
);
2508 if (SUCCEEDED(hr
) && out_params
)
2510 hr
= SWbemObject_create( services
, out_params
, out_sparams
);
2511 IWbemClassObject_Release( out_params
);
2517 static HRESULT WINAPI
services_ExecMethodAsync(
2518 ISWbemServices
*iface
,
2519 IDispatch
*objWbemSink
,
2522 IDispatch
*objWbemInParameters
,
2524 IDispatch
*objWbemNamedValueSet
,
2525 IDispatch
*objWbemAsyncContext
)
2531 static HRESULT WINAPI
services_get_Security_(
2532 ISWbemServices
*iface
,
2533 ISWbemSecurity
**objWbemSecurity
)
2535 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
2537 if (!objWbemSecurity
)
2538 return E_INVALIDARG
;
2540 return ISWbemSecurity_create( objWbemSecurity
);
2543 static const ISWbemServicesVtbl services_vtbl
=
2545 services_QueryInterface
,
2548 services_GetTypeInfoCount
,
2549 services_GetTypeInfo
,
2550 services_GetIDsOfNames
,
2555 services_DeleteAsync
,
2556 services_InstancesOf
,
2557 services_InstancesOfAsync
,
2558 services_SubclassesOf
,
2559 services_SubclassesOfAsync
,
2561 services_ExecQueryAsync
,
2562 services_AssociatorsOf
,
2563 services_AssociatorsOfAsync
,
2564 services_ReferencesTo
,
2565 services_ReferencesToAsync
,
2566 services_ExecNotificationQuery
,
2567 services_ExecNotificationQueryAsync
,
2568 services_ExecMethod
,
2569 services_ExecMethodAsync
,
2570 services_get_Security_
2573 static HRESULT
SWbemServices_create( IWbemServices
*wbem_services
, ISWbemServices
**obj
)
2575 struct services
*services
;
2577 TRACE( "%p, %p\n", obj
, wbem_services
);
2579 if (!(services
= malloc( sizeof(*services
) ))) return E_OUTOFMEMORY
;
2580 services
->ISWbemServices_iface
.lpVtbl
= &services_vtbl
;
2582 services
->services
= wbem_services
;
2583 IWbemServices_AddRef( services
->services
);
2585 *obj
= &services
->ISWbemServices_iface
;
2586 TRACE( "returning iface %p\n", *obj
);
2592 ISWbemLocator ISWbemLocator_iface
;
2594 IWbemLocator
*locator
;
2597 static inline struct locator
*impl_from_ISWbemLocator( ISWbemLocator
*iface
)
2599 return CONTAINING_RECORD( iface
, struct locator
, ISWbemLocator_iface
);
2602 static ULONG WINAPI
locator_AddRef(
2603 ISWbemLocator
*iface
)
2605 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2606 return InterlockedIncrement( &locator
->refs
);
2609 static ULONG WINAPI
locator_Release(
2610 ISWbemLocator
*iface
)
2612 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2613 LONG refs
= InterlockedDecrement( &locator
->refs
);
2616 TRACE( "destroying %p\n", locator
);
2617 if (locator
->locator
)
2618 IWbemLocator_Release( locator
->locator
);
2624 static HRESULT WINAPI
locator_QueryInterface(
2625 ISWbemLocator
*iface
,
2629 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2631 TRACE( "%p, %s, %p\n", locator
, debugstr_guid( riid
), ppvObject
);
2633 if (IsEqualGUID( riid
, &IID_ISWbemLocator
) ||
2634 IsEqualGUID( riid
, &IID_IDispatch
) ||
2635 IsEqualGUID( riid
, &IID_IUnknown
))
2641 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2642 return E_NOINTERFACE
;
2644 ISWbemLocator_AddRef( iface
);
2648 static HRESULT WINAPI
locator_GetTypeInfoCount(
2649 ISWbemLocator
*iface
,
2652 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2654 TRACE( "%p, %p\n", locator
, count
);
2659 static HRESULT WINAPI
locator_GetTypeInfo(
2660 ISWbemLocator
*iface
,
2665 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2666 TRACE( "%p, %u, %#lx, %p\n", locator
, index
, lcid
, info
);
2668 return get_typeinfo( ISWbemLocator_tid
, info
);
2671 static HRESULT WINAPI
locator_GetIDsOfNames(
2672 ISWbemLocator
*iface
,
2679 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2680 ITypeInfo
*typeinfo
;
2683 TRACE( "%p, %s, %p, %u, %#lx, %p\n", locator
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2685 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2687 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2690 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2691 ITypeInfo_Release( typeinfo
);
2696 static HRESULT WINAPI
locator_Invoke(
2697 ISWbemLocator
*iface
,
2704 EXCEPINFO
*excep_info
,
2707 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2708 ITypeInfo
*typeinfo
;
2711 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", locator
, member
, debugstr_guid(riid
),
2712 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2714 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2717 hr
= ITypeInfo_Invoke( typeinfo
, &locator
->ISWbemLocator_iface
, member
, flags
,
2718 params
, result
, excep_info
, arg_err
);
2719 ITypeInfo_Release( typeinfo
);
2724 static BSTR
build_resource_string( BSTR server
, BSTR
namespace )
2726 ULONG len
, len_server
= 0, len_namespace
= 0;
2729 if (server
&& *server
) len_server
= lstrlenW( server
);
2730 else len_server
= 1;
2731 if (namespace && *namespace) len_namespace
= lstrlenW( namespace );
2732 else len_namespace
= ARRAY_SIZE(L
"root\\default") - 1;
2734 if (!(ret
= SysAllocStringLen( NULL
, 2 + len_server
+ 1 + len_namespace
))) return NULL
;
2736 ret
[0] = ret
[1] = '\\';
2737 if (server
&& *server
) lstrcpyW( ret
+ 2, server
);
2740 len
= len_server
+ 2;
2743 if (namespace && *namespace) lstrcpyW( ret
+ len
, namespace );
2744 else lstrcpyW( ret
+ len
, L
"root\\default" );
2748 static HRESULT WINAPI
locator_ConnectServer(
2749 ISWbemLocator
*iface
,
2756 LONG iSecurityFlags
,
2757 IDispatch
*objWbemNamedValueSet
,
2758 ISWbemServices
**objWbemServices
)
2760 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2761 IWbemServices
*services
;
2762 IWbemContext
*context
;
2766 TRACE( "%p, %s, %s, %s, %p, %s, %s, %#lx, %p, %p\n", iface
, debugstr_w(strServer
),
2767 debugstr_w(strNamespace
), debugstr_w(strUser
), strPassword
, debugstr_w(strLocale
),
2768 debugstr_w(strAuthority
), iSecurityFlags
, objWbemNamedValueSet
, objWbemServices
);
2770 if (!locator
->locator
)
2772 hr
= CoCreateInstance( &CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
,
2773 (void **)&locator
->locator
);
2774 if (hr
!= S_OK
) return hr
;
2777 context
= unsafe_get_context_from_namedvalueset( objWbemNamedValueSet
);
2779 if (!(resource
= build_resource_string( strServer
, strNamespace
))) return E_OUTOFMEMORY
;
2780 hr
= IWbemLocator_ConnectServer( locator
->locator
, resource
, strUser
, strPassword
, strLocale
,
2781 iSecurityFlags
, strAuthority
, context
, &services
);
2782 SysFreeString( resource
);
2783 if (hr
!= S_OK
) return hr
;
2785 hr
= SWbemServices_create( services
, objWbemServices
);
2786 IWbemServices_Release( services
);
2790 static HRESULT WINAPI
locator_get_Security_(
2791 ISWbemLocator
*iface
,
2792 ISWbemSecurity
**objWbemSecurity
)
2794 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
2796 if (!objWbemSecurity
)
2797 return E_INVALIDARG
;
2799 return ISWbemSecurity_create( objWbemSecurity
);
2802 static const ISWbemLocatorVtbl locator_vtbl
=
2804 locator_QueryInterface
,
2807 locator_GetTypeInfoCount
,
2808 locator_GetTypeInfo
,
2809 locator_GetIDsOfNames
,
2811 locator_ConnectServer
,
2812 locator_get_Security_
2815 HRESULT
SWbemLocator_create( void **obj
)
2817 struct locator
*locator
;
2819 TRACE( "%p\n", obj
);
2821 if (!(locator
= malloc( sizeof(*locator
) ))) return E_OUTOFMEMORY
;
2822 locator
->ISWbemLocator_iface
.lpVtbl
= &locator_vtbl
;
2824 locator
->locator
= NULL
;
2826 *obj
= &locator
->ISWbemLocator_iface
;
2827 TRACE( "returning iface %p\n", *obj
);
2833 ISWbemSecurity ISWbemSecurity_iface
;
2835 WbemImpersonationLevelEnum implevel
;
2836 WbemAuthenticationLevelEnum authlevel
;
2839 static inline struct security
*impl_from_ISWbemSecurity( ISWbemSecurity
*iface
)
2841 return CONTAINING_RECORD( iface
, struct security
, ISWbemSecurity_iface
);
2844 static ULONG WINAPI
security_AddRef(
2845 ISWbemSecurity
*iface
)
2847 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2848 return InterlockedIncrement( &security
->refs
);
2851 static ULONG WINAPI
security_Release(
2852 ISWbemSecurity
*iface
)
2854 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2855 LONG refs
= InterlockedDecrement( &security
->refs
);
2858 TRACE( "destroying %p\n", security
);
2864 static HRESULT WINAPI
security_QueryInterface(
2865 ISWbemSecurity
*iface
,
2869 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2870 TRACE( "%p, %s, %p\n", security
, debugstr_guid( riid
), ppvObject
);
2872 if (IsEqualGUID( riid
, &IID_ISWbemSecurity
) ||
2873 IsEqualGUID( riid
, &IID_IDispatch
) ||
2874 IsEqualGUID( riid
, &IID_IUnknown
))
2880 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2881 return E_NOINTERFACE
;
2883 ISWbemSecurity_AddRef( iface
);
2887 static HRESULT WINAPI
security_GetTypeInfoCount(
2888 ISWbemSecurity
*iface
,
2891 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2892 TRACE( "%p, %p\n", security
, count
);
2898 static HRESULT WINAPI
security_GetTypeInfo(
2899 ISWbemSecurity
*iface
,
2904 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2905 TRACE( "%p, %u, %#lx, %p\n", security
, index
, lcid
, info
);
2907 return get_typeinfo( ISWbemSecurity_tid
, info
);
2910 static HRESULT WINAPI
security_GetIDsOfNames(
2911 ISWbemSecurity
*iface
,
2918 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2919 ITypeInfo
*typeinfo
;
2922 TRACE( "%p, %s, %p, %u, %#lx, %p\n", security
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2924 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2926 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2929 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2930 ITypeInfo_Release( typeinfo
);
2935 static HRESULT WINAPI
security_Invoke(
2936 ISWbemSecurity
*iface
,
2943 EXCEPINFO
*excep_info
,
2946 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2947 ITypeInfo
*typeinfo
;
2950 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", security
, member
, debugstr_guid(riid
),
2951 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2953 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2956 hr
= ITypeInfo_Invoke( typeinfo
, &security
->ISWbemSecurity_iface
, member
, flags
,
2957 params
, result
, excep_info
, arg_err
);
2958 ITypeInfo_Release( typeinfo
);
2963 static HRESULT WINAPI
security_get_ImpersonationLevel(
2964 ISWbemSecurity
*iface
,
2965 WbemImpersonationLevelEnum
*impersonation_level
)
2967 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2968 FIXME( "%p, %p: stub\n", security
, impersonation_level
);
2970 if (!impersonation_level
)
2971 return E_INVALIDARG
;
2973 *impersonation_level
= security
->implevel
;
2977 static HRESULT WINAPI
security_put_ImpersonationLevel(
2978 ISWbemSecurity
*iface
,
2979 WbemImpersonationLevelEnum impersonation_level
)
2981 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2982 FIXME( "%p, %d: stub\n", security
, impersonation_level
);
2984 security
->implevel
= impersonation_level
;
2988 static HRESULT WINAPI
security_get_AuthenticationLevel(
2989 ISWbemSecurity
*iface
,
2990 WbemAuthenticationLevelEnum
*authentication_level
)
2992 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2993 FIXME( "%p, %p: stub\n", security
, authentication_level
);
2995 if (!authentication_level
)
2996 return E_INVALIDARG
;
2998 *authentication_level
= security
->authlevel
;
3002 static HRESULT WINAPI
security_put_AuthenticationLevel(
3003 ISWbemSecurity
*iface
,
3004 WbemAuthenticationLevelEnum authentication_level
)
3006 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3007 FIXME( "%p, %d: stub\n", security
, authentication_level
);
3009 security
->authlevel
= authentication_level
;
3013 static HRESULT WINAPI
security_get_Privileges(
3014 ISWbemSecurity
*iface
,
3015 ISWbemPrivilegeSet
**privilege_set
)
3017 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3018 FIXME( "%p, %p: stub\n", security
, privilege_set
);
3021 return E_INVALIDARG
;
3026 static const ISWbemSecurityVtbl security_vtbl
=
3028 security_QueryInterface
,
3031 security_GetTypeInfoCount
,
3032 security_GetTypeInfo
,
3033 security_GetIDsOfNames
,
3035 security_get_ImpersonationLevel
,
3036 security_put_ImpersonationLevel
,
3037 security_get_AuthenticationLevel
,
3038 security_put_AuthenticationLevel
,
3039 security_get_Privileges
3042 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
**obj
)
3044 struct security
*security
;
3046 TRACE( "%p\n", obj
);
3048 if (!(security
= malloc( sizeof(*security
) ))) return E_OUTOFMEMORY
;
3049 security
->ISWbemSecurity_iface
.lpVtbl
= &security_vtbl
;
3051 security
->implevel
= wbemImpersonationLevelImpersonate
;
3052 security
->authlevel
= wbemAuthenticationLevelPktPrivacy
;
3054 *obj
= &security
->ISWbemSecurity_iface
;
3055 TRACE( "returning iface %p\n", *obj
);
3061 ISWbemNamedValue ISWbemNamedValue_iface
;
3065 static struct namedvalueset
*impl_from_ISWbemNamedValueSet( ISWbemNamedValueSet
*iface
)
3067 return CONTAINING_RECORD( iface
, struct namedvalueset
, ISWbemNamedValueSet_iface
);
3070 static struct namedvalue
*impl_from_ISWbemNamedValue( ISWbemNamedValue
*iface
)
3072 return CONTAINING_RECORD( iface
, struct namedvalue
, ISWbemNamedValue_iface
);
3075 static HRESULT WINAPI
namedvalue_QueryInterface(
3076 ISWbemNamedValue
*iface
,
3080 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3082 TRACE( "%p, %s, %p\n", value
, debugstr_guid( riid
), ppvObject
);
3084 if (IsEqualGUID( riid
, &IID_ISWbemNamedValue
) ||
3085 IsEqualGUID( riid
, &IID_IDispatch
) ||
3086 IsEqualGUID( riid
, &IID_IUnknown
))
3092 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
3093 return E_NOINTERFACE
;
3095 ISWbemNamedValue_AddRef( iface
);
3099 static ULONG WINAPI
namedvalue_AddRef(
3100 ISWbemNamedValue
*iface
)
3102 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3103 return InterlockedIncrement( &value
->refs
);
3106 static ULONG WINAPI
namedvalue_Release(
3107 ISWbemNamedValue
*iface
)
3109 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3110 LONG refs
= InterlockedDecrement( &value
->refs
);
3113 TRACE( "destroying %p\n", value
);
3119 static HRESULT WINAPI
namedvalue_GetTypeInfoCount(
3120 ISWbemNamedValue
*iface
,
3123 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3124 TRACE( "%p, %p\n", value
, count
);
3130 static HRESULT WINAPI
namedvalue_GetTypeInfo(
3131 ISWbemNamedValue
*iface
,
3136 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3138 TRACE( "%p, %u, %#lx, %p\n", value
, index
, lcid
, info
);
3140 return get_typeinfo( ISWbemNamedValue_tid
, info
);
3143 static HRESULT WINAPI
namedvalue_GetIDsOfNames(
3144 ISWbemNamedValue
*iface
,
3151 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3152 ITypeInfo
*typeinfo
;
3155 TRACE( "%p, %s, %p, %u, %#lx, %p\n", value
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3157 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
3159 hr
= get_typeinfo( ISWbemNamedValue_tid
, &typeinfo
);
3162 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
3163 ITypeInfo_Release( typeinfo
);
3168 static HRESULT WINAPI
namedvalue_Invoke(
3169 ISWbemNamedValue
*iface
,
3176 EXCEPINFO
*excep_info
,
3179 struct namedvalue
*set
= impl_from_ISWbemNamedValue( iface
);
3180 ITypeInfo
*typeinfo
;
3183 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
3184 lcid
, flags
, params
, result
, excep_info
, arg_err
);
3186 hr
= get_typeinfo( ISWbemNamedValue_tid
, &typeinfo
);
3189 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemNamedValue_iface
, member
, flags
,
3190 params
, result
, excep_info
, arg_err
);
3191 ITypeInfo_Release( typeinfo
);
3196 static HRESULT WINAPI
namedvalue_get_Value(
3197 ISWbemNamedValue
*iface
,
3205 static HRESULT WINAPI
namedvalue_put_Value(
3206 ISWbemNamedValue
*iface
,
3214 static HRESULT WINAPI
namedvalue_get_Name(
3215 ISWbemNamedValue
*iface
,
3223 static const ISWbemNamedValueVtbl namedvaluevtbl
=
3225 namedvalue_QueryInterface
,
3228 namedvalue_GetTypeInfoCount
,
3229 namedvalue_GetTypeInfo
,
3230 namedvalue_GetIDsOfNames
,
3232 namedvalue_get_Value
,
3233 namedvalue_put_Value
,
3237 static HRESULT
namedvalue_create( ISWbemNamedValue
**value
)
3239 struct namedvalue
*object
;
3241 if (!(object
= malloc( sizeof(*object
) ))) return E_OUTOFMEMORY
;
3243 object
->ISWbemNamedValue_iface
.lpVtbl
= &namedvaluevtbl
;
3246 *value
= &object
->ISWbemNamedValue_iface
;
3251 static HRESULT WINAPI
namedvalueset_QueryInterface(
3252 ISWbemNamedValueSet
*iface
,
3256 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3258 TRACE( "%p, %s, %p\n", set
, debugstr_guid( riid
), ppvObject
);
3260 if (IsEqualGUID( riid
, &IID_ISWbemNamedValueSet
) ||
3261 IsEqualGUID( riid
, &IID_IDispatch
) ||
3262 IsEqualGUID( riid
, &IID_IUnknown
))
3268 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
3269 return E_NOINTERFACE
;
3271 ISWbemNamedValueSet_AddRef( iface
);
3275 static ULONG WINAPI
namedvalueset_AddRef(
3276 ISWbemNamedValueSet
*iface
)
3278 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3279 return InterlockedIncrement( &set
->refs
);
3282 static ULONG WINAPI
namedvalueset_Release(
3283 ISWbemNamedValueSet
*iface
)
3285 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3286 LONG refs
= InterlockedDecrement( &set
->refs
);
3289 TRACE( "destroying %p\n", set
);
3291 IWbemContext_Release( set
->context
);
3297 static HRESULT WINAPI
namedvalueset_GetTypeInfoCount(
3298 ISWbemNamedValueSet
*iface
,
3301 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3302 TRACE( "%p, %p\n", set
, count
);
3308 static HRESULT WINAPI
namedvalueset_GetTypeInfo(
3309 ISWbemNamedValueSet
*iface
,
3314 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3316 TRACE( "%p, %u, %#lx, %p\n", set
, index
, lcid
, info
);
3318 return get_typeinfo( ISWbemNamedValueSet_tid
, info
);
3321 static HRESULT WINAPI
namedvalueset_GetIDsOfNames(
3322 ISWbemNamedValueSet
*iface
,
3329 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3330 ITypeInfo
*typeinfo
;
3333 TRACE( "%p, %s, %p, %u, %#lx, %p\n", set
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3335 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
3337 hr
= get_typeinfo( ISWbemNamedValueSet_tid
, &typeinfo
);
3340 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
3341 ITypeInfo_Release( typeinfo
);
3346 static HRESULT WINAPI
namedvalueset_Invoke(
3347 ISWbemNamedValueSet
*iface
,
3354 EXCEPINFO
*excep_info
,
3357 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3358 ITypeInfo
*typeinfo
;
3361 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
3362 lcid
, flags
, params
, result
, excep_info
, arg_err
);
3364 hr
= get_typeinfo( ISWbemNamedValueSet_tid
, &typeinfo
);
3367 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemNamedValueSet_iface
, member
, flags
,
3368 params
, result
, excep_info
, arg_err
);
3369 ITypeInfo_Release( typeinfo
);
3374 static HRESULT WINAPI
namedvalueset_get__NewEnum(
3375 ISWbemNamedValueSet
*iface
,
3383 static HRESULT WINAPI
namedvalueset_Item(
3384 ISWbemNamedValueSet
*iface
,
3387 ISWbemNamedValue
**value
)
3389 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3393 TRACE("%p, %s, %#lx, %p\n", set
, debugstr_w(name
), flags
, value
);
3395 if (SUCCEEDED(hr
= IWbemContext_GetValue( set
->context
, name
, flags
, &var
)))
3397 VariantClear( &var
);
3398 hr
= namedvalue_create( value
);
3404 static HRESULT WINAPI
namedvalueset_get_Count(
3405 ISWbemNamedValueSet
*iface
,
3413 static HRESULT WINAPI
namedvalueset_Add(
3414 ISWbemNamedValueSet
*iface
,
3418 ISWbemNamedValue
**value
)
3420 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3423 TRACE("%p, %s, %s, %#lx, %p\n", set
, debugstr_w(name
), debugstr_variant(var
), flags
, value
);
3425 if (!name
|| !var
|| !value
)
3426 return WBEM_E_INVALID_PARAMETER
;
3428 if (SUCCEEDED(hr
= IWbemContext_SetValue( set
->context
, name
, flags
, var
)))
3430 hr
= namedvalue_create( value
);
3436 static HRESULT WINAPI
namedvalueset_Remove(
3437 ISWbemNamedValueSet
*iface
,
3441 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3443 TRACE("%p, %s, %#lx\n", set
, debugstr_w(name
), flags
);
3445 return IWbemContext_DeleteValue( set
->context
, name
, flags
);
3448 static HRESULT WINAPI
namedvalueset_Clone(
3449 ISWbemNamedValueSet
*iface
,
3450 ISWbemNamedValueSet
**valueset
)
3457 static HRESULT WINAPI
namedvalueset_DeleteAll(
3458 ISWbemNamedValueSet
*iface
)
3460 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3464 return IWbemContext_DeleteAll( set
->context
);
3467 static const ISWbemNamedValueSetVtbl namedvalueset_vtbl
=
3469 namedvalueset_QueryInterface
,
3470 namedvalueset_AddRef
,
3471 namedvalueset_Release
,
3472 namedvalueset_GetTypeInfoCount
,
3473 namedvalueset_GetTypeInfo
,
3474 namedvalueset_GetIDsOfNames
,
3475 namedvalueset_Invoke
,
3476 namedvalueset_get__NewEnum
,
3478 namedvalueset_get_Count
,
3480 namedvalueset_Remove
,
3481 namedvalueset_Clone
,
3482 namedvalueset_DeleteAll
,
3485 static struct namedvalueset
*unsafe_valueset_impl_from_IDispatch(IDispatch
*iface
)
3489 if (iface
->lpVtbl
!= (IDispatchVtbl
*)&namedvalueset_vtbl
)
3491 FIXME( "External implementations are not supported.\n" );
3494 return CONTAINING_RECORD(iface
, struct namedvalueset
, ISWbemNamedValueSet_iface
);
3497 HRESULT
SWbemNamedValueSet_create( void **obj
)
3499 struct namedvalueset
*set
;
3502 TRACE( "%p\n", obj
);
3504 if (!(set
= calloc( 1, sizeof(*set
) ))) return E_OUTOFMEMORY
;
3505 set
->ISWbemNamedValueSet_iface
.lpVtbl
= &namedvalueset_vtbl
;
3508 if (FAILED(hr
= CoCreateInstance( &CLSID_WbemContext
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemContext
,
3509 (void **)&set
->context
)))
3511 ISWbemNamedValueSet_Release( &set
->ISWbemNamedValueSet_iface
);
3515 *obj
= &set
->ISWbemNamedValueSet_iface
;
3516 TRACE( "returning iface %p\n", *obj
);