2 * StdRegProv implementation
4 * Copyright 2012 Hans Leidekker for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/debug.h"
30 #include "wbemprox_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
34 static HRESULT
to_bstr_array( BSTR
*strings
, DWORD count
, VARIANT
*var
)
40 if (!(sa
= SafeArrayCreateVector( VT_BSTR
, 0, count
))) return E_OUTOFMEMORY
;
41 for (i
= 0; i
< count
; i
++)
43 if ((hr
= SafeArrayPutElement( sa
, &i
, strings
[i
] )) != S_OK
)
45 SafeArrayDestroy( sa
);
49 set_variant( VT_BSTR
|VT_ARRAY
, 0, sa
, var
);
53 static void free_bstr_array( BSTR
*strings
, DWORD count
)
56 SysFreeString( *(strings
++) );
59 static HRESULT
to_i4_array( DWORD
*values
, DWORD count
, VARIANT
*var
)
65 if (!(sa
= SafeArrayCreateVector( VT_I4
, 0, count
))) return E_OUTOFMEMORY
;
66 for (i
= 0; i
< count
; i
++)
68 if ((hr
= SafeArrayPutElement( sa
, &i
, &values
[i
] )) != S_OK
)
70 SafeArrayDestroy( sa
);
74 set_variant( VT_I4
|VT_ARRAY
, 0, sa
, var
);
78 static unsigned int get_access_mask( IWbemContext
*context
)
82 if (!context
) return 0;
84 V_VT( &value
) = VT_EMPTY
;
85 if (FAILED(IWbemContext_GetValue( context
, L
"__ProviderArchitecture", 0, &value
)))
88 if (FAILED(VariantChangeType( &value
, &value
, 0, VT_I4
)))
90 VariantClear( &value
);
94 if (V_I4( &value
) == 32)
95 return KEY_WOW64_32KEY
;
96 else if (V_I4( &value
) == 64)
97 return KEY_WOW64_64KEY
;
102 static HRESULT
create_key( HKEY root
, const WCHAR
*subkey
, IWbemContext
*context
, VARIANT
*retval
)
107 TRACE("%p, %s\n", root
, debugstr_w(subkey
));
109 res
= RegCreateKeyExW( root
, subkey
, 0, NULL
, 0, get_access_mask( context
), NULL
, &hkey
, NULL
);
110 set_variant( VT_UI4
, res
, NULL
, retval
);
116 return HRESULT_FROM_WIN32( res
);
119 HRESULT
reg_create_key( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
121 VARIANT defkey
, subkey
, retval
;
122 IWbemClassObject
*sig
, *out_params
= NULL
;
125 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
127 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
128 if (hr
!= S_OK
) return hr
;
129 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
130 if (hr
!= S_OK
) return hr
;
132 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"CreateKey", PARAM_OUT
, &sig
);
135 VariantClear( &subkey
);
140 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
143 VariantClear( &subkey
);
144 IWbemClassObject_Release( sig
);
148 hr
= create_key( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), context
, &retval
);
149 if (hr
== S_OK
&& out_params
)
150 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
152 VariantClear( &subkey
);
153 IWbemClassObject_Release( sig
);
154 if (hr
== S_OK
&& out
)
157 IWbemClassObject_AddRef( out_params
);
159 if (out_params
) IWbemClassObject_Release( out_params
);
163 static HRESULT
enum_key( HKEY root
, const WCHAR
*subkey
, VARIANT
*names
, IWbemContext
*context
, VARIANT
*retval
)
169 DWORD count
= 2, len
= ARRAY_SIZE( buf
);
172 TRACE("%p, %s\n", root
, debugstr_w(subkey
));
174 if (!(strings
= malloc( count
* sizeof(BSTR
) ))) return E_OUTOFMEMORY
;
175 if ((res
= RegOpenKeyExW( root
, subkey
, 0, KEY_ENUMERATE_SUB_KEYS
| get_access_mask( context
), &hkey
)))
177 set_variant( VT_UI4
, res
, NULL
, retval
);
186 if (!(tmp
= realloc( strings
, count
* sizeof(BSTR
) )))
190 return E_OUTOFMEMORY
;
194 if ((res
= RegEnumKeyW( hkey
, i
, buf
, len
)) == ERROR_NO_MORE_ITEMS
)
196 if (i
) res
= ERROR_SUCCESS
;
200 if (!(strings
[i
] = SysAllocString( buf
)))
202 for (i
--; i
>= 0; i
--) SysFreeString( strings
[i
] );
208 if (hr
== S_OK
&& !res
)
210 hr
= to_bstr_array( strings
, i
, names
);
211 free_bstr_array( strings
, i
);
213 set_variant( VT_UI4
, res
, NULL
, retval
);
219 HRESULT
reg_enum_key( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
221 VARIANT defkey
, subkey
, names
, retval
;
222 IWbemClassObject
*sig
, *out_params
= NULL
;
225 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
227 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
228 if (hr
!= S_OK
) return hr
;
229 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
230 if (hr
!= S_OK
) return hr
;
232 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"EnumKey", PARAM_OUT
, &sig
);
235 VariantClear( &subkey
);
240 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
243 VariantClear( &subkey
);
244 IWbemClassObject_Release( sig
);
248 VariantInit( &names
);
249 hr
= enum_key( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), &names
, context
, &retval
);
250 if (hr
!= S_OK
) goto done
;
253 if (!V_UI4( &retval
))
255 hr
= IWbemClassObject_Put( out_params
, L
"sNames", 0, &names
, CIM_STRING
|CIM_FLAG_ARRAY
);
256 if (hr
!= S_OK
) goto done
;
258 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
262 VariantClear( &names
);
263 VariantClear( &subkey
);
264 IWbemClassObject_Release( sig
);
265 if (hr
== S_OK
&& out
)
268 IWbemClassObject_AddRef( out_params
);
270 if (out_params
) IWbemClassObject_Release( out_params
);
274 static HRESULT
enum_values( HKEY root
, const WCHAR
*subkey
, VARIANT
*names
, VARIANT
*types
, IWbemContext
*context
,
279 BSTR
*value_names
= NULL
;
280 DWORD count
, buflen
, len
, *value_types
= NULL
;
284 TRACE("%p, %s\n", root
, debugstr_w(subkey
));
286 if ((res
= RegOpenKeyExW( root
, subkey
, 0, KEY_QUERY_VALUE
| get_access_mask( context
), &hkey
))) goto done
;
287 if ((res
= RegQueryInfoKeyW( hkey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &count
, &buflen
, NULL
, NULL
, NULL
)))
291 if (!(buf
= malloc( (buflen
+ 1) * sizeof(WCHAR
) ))) goto done
;
292 if (!(value_names
= malloc( count
* sizeof(BSTR
) ))) goto done
;
293 if (!(value_types
= malloc( count
* sizeof(DWORD
) ))) goto done
;
299 res
= RegEnumValueW( hkey
, i
, buf
, &len
, NULL
, &value_types
[i
], NULL
, NULL
);
300 if (res
== ERROR_NO_MORE_ITEMS
)
302 if (i
) res
= ERROR_SUCCESS
;
306 if (!(value_names
[i
] = SysAllocString( buf
)))
308 for (i
--; i
>= 0; i
--) SysFreeString( value_names
[i
] );
314 if (hr
== S_OK
&& !res
)
316 hr
= to_bstr_array( value_names
, i
, names
);
317 free_bstr_array( value_names
, i
);
318 if (hr
== S_OK
) hr
= to_i4_array( value_types
, i
, types
);
322 set_variant( VT_UI4
, res
, NULL
, retval
);
330 HRESULT
reg_enum_values( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
332 VARIANT defkey
, subkey
, names
, types
, retval
;
333 IWbemClassObject
*sig
, *out_params
= NULL
;
336 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
338 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
339 if (hr
!= S_OK
) return hr
;
340 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
341 if (hr
!= S_OK
) return hr
;
343 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"EnumValues", PARAM_OUT
, &sig
);
346 VariantClear( &subkey
);
351 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
354 VariantClear( &subkey
);
355 IWbemClassObject_Release( sig
);
359 VariantInit( &names
);
360 VariantInit( &types
);
361 hr
= enum_values( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), &names
, &types
, context
, &retval
);
362 if (hr
!= S_OK
) goto done
;
365 if (!V_UI4( &retval
))
367 hr
= IWbemClassObject_Put( out_params
, L
"sNames", 0, &names
, CIM_STRING
|CIM_FLAG_ARRAY
);
368 if (hr
!= S_OK
) goto done
;
369 hr
= IWbemClassObject_Put( out_params
, L
"Types", 0, &types
, CIM_SINT32
|CIM_FLAG_ARRAY
);
370 if (hr
!= S_OK
) goto done
;
372 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
376 VariantClear( &types
);
377 VariantClear( &names
);
378 VariantClear( &subkey
);
379 IWbemClassObject_Release( sig
);
380 if (hr
== S_OK
&& out
)
383 IWbemClassObject_AddRef( out_params
);
385 if (out_params
) IWbemClassObject_Release( out_params
);
389 static HRESULT
get_stringvalue( HKEY root
, const WCHAR
*subkey
, const WCHAR
*name
, VARIANT
*value
,
390 IWbemContext
*context
, VARIANT
*retval
)
392 DWORD size
, mask
, flags
= RRF_RT_REG_SZ
;
397 TRACE("%p, %s, %s\n", root
, debugstr_w(subkey
), debugstr_w(name
));
399 mask
= get_access_mask( context
);
401 if (mask
& KEY_WOW64_64KEY
)
402 flags
|= RRF_SUBKEY_WOW6464KEY
;
403 else if (mask
& KEY_WOW64_32KEY
)
404 flags
|= RRF_SUBKEY_WOW6432KEY
;
406 if ((res
= RegGetValueW( root
, subkey
, name
, flags
, NULL
, NULL
, &size
))) goto done
;
407 if (!(str
= SysAllocStringLen( NULL
, size
/ sizeof(WCHAR
) - 1 ))) return E_OUTOFMEMORY
;
408 if (!(res
= RegGetValueW( root
, subkey
, name
, flags
, NULL
, str
, &size
))) set_variant( VT_BSTR
, 0, str
, value
);
411 set_variant( VT_UI4
, res
, NULL
, retval
);
412 if (res
) SysFreeString( str
);
416 HRESULT
reg_get_stringvalue( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
418 VARIANT defkey
, subkey
, name
, value
, retval
;
419 IWbemClassObject
*sig
, *out_params
= NULL
;
422 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
424 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
425 if (hr
!= S_OK
) return hr
;
426 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
427 if (hr
!= S_OK
) return hr
;
428 hr
= IWbemClassObject_Get( in
, L
"sValueName", 0, &name
, NULL
, NULL
);
431 VariantClear( &subkey
);
435 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"GetStringValue", PARAM_OUT
, &sig
);
438 VariantClear( &name
);
439 VariantClear( &subkey
);
444 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
447 VariantClear( &name
);
448 VariantClear( &subkey
);
449 IWbemClassObject_Release( sig
);
453 VariantInit( &value
);
454 hr
= get_stringvalue( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), V_BSTR(&name
), &value
, context
, &retval
);
455 if (hr
!= S_OK
) goto done
;
458 if (!V_UI4( &retval
))
460 hr
= IWbemClassObject_Put( out_params
, L
"sValue", 0, &value
, CIM_STRING
);
461 if (hr
!= S_OK
) goto done
;
463 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
467 VariantClear( &name
);
468 VariantClear( &subkey
);
469 IWbemClassObject_Release( sig
);
470 if (hr
== S_OK
&& out
)
473 IWbemClassObject_AddRef( out_params
);
475 if (out_params
) IWbemClassObject_Release( out_params
);
479 static HRESULT
to_ui1_array( BYTE
*value
, DWORD size
, VARIANT
*var
)
485 if (!(sa
= SafeArrayCreateVector( VT_UI1
, 0, size
))) return E_OUTOFMEMORY
;
486 for (i
= 0; i
< size
; i
++)
488 if ((hr
= SafeArrayPutElement( sa
, &i
, &value
[i
] )) != S_OK
)
490 SafeArrayDestroy( sa
);
494 set_variant( VT_UI1
|VT_ARRAY
, 0, sa
, var
);
498 static HRESULT
get_binaryvalue( HKEY root
, const WCHAR
*subkey
, const WCHAR
*name
, VARIANT
*value
,
499 IWbemContext
*context
, VARIANT
*retval
)
501 DWORD size
, mask
, flags
= RRF_RT_REG_BINARY
;
506 TRACE("%p, %s, %s\n", root
, debugstr_w(subkey
), debugstr_w(name
));
508 mask
= get_access_mask( context
);
510 if (mask
& KEY_WOW64_64KEY
)
511 flags
|= RRF_SUBKEY_WOW6464KEY
;
512 else if (mask
& KEY_WOW64_32KEY
)
513 flags
|= RRF_SUBKEY_WOW6432KEY
;
515 if ((res
= RegGetValueW( root
, subkey
, name
, flags
, NULL
, NULL
, &size
))) goto done
;
516 if (!(buf
= malloc( size
))) return E_OUTOFMEMORY
;
517 if (!(res
= RegGetValueW( root
, subkey
, name
, flags
, NULL
, buf
, &size
))) hr
= to_ui1_array( buf
, size
, value
);
520 set_variant( VT_UI4
, res
, NULL
, retval
);
525 HRESULT
reg_get_binaryvalue( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
527 VARIANT defkey
, subkey
, name
, value
, retval
;
528 IWbemClassObject
*sig
, *out_params
= NULL
;
531 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
533 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
534 if (hr
!= S_OK
) return hr
;
535 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
536 if (hr
!= S_OK
) return hr
;
537 hr
= IWbemClassObject_Get( in
, L
"sValueName", 0, &name
, NULL
, NULL
);
540 VariantClear( &subkey
);
544 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"GetBinaryValue", PARAM_OUT
, &sig
);
547 VariantClear( &name
);
548 VariantClear( &subkey
);
553 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
556 VariantClear( &name
);
557 VariantClear( &subkey
);
558 IWbemClassObject_Release( sig
);
562 VariantInit( &value
);
563 hr
= get_binaryvalue( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), V_BSTR(&name
), &value
, context
, &retval
);
564 if (hr
!= S_OK
) goto done
;
567 if (!V_UI4( &retval
))
569 hr
= IWbemClassObject_Put( out_params
, L
"uValue", 0, &value
, CIM_UINT8
|CIM_FLAG_ARRAY
);
570 if (hr
!= S_OK
) goto done
;
572 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
576 VariantClear( &name
);
577 VariantClear( &subkey
);
578 IWbemClassObject_Release( sig
);
579 if (hr
== S_OK
&& out
)
582 IWbemClassObject_AddRef( out_params
);
584 if (out_params
) IWbemClassObject_Release( out_params
);
588 static void set_stringvalue( HKEY root
, const WCHAR
*subkey
, const WCHAR
*name
, const WCHAR
*value
,
589 IWbemContext
*context
, VARIANT
*retval
)
594 TRACE("%p, %s, %s, %s\n", root
, debugstr_w(subkey
), debugstr_w(name
), debugstr_w(value
));
596 if ((res
= RegOpenKeyExW( root
, subkey
, 0, KEY_SET_VALUE
| get_access_mask( context
), &hkey
)))
598 set_variant( VT_UI4
, res
, NULL
, retval
);
602 res
= RegSetKeyValueW( hkey
, NULL
, name
, REG_SZ
, value
, (lstrlenW( value
) + 1) * sizeof(*value
) );
603 set_variant( VT_UI4
, res
, NULL
, retval
);
607 HRESULT
reg_set_stringvalue( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
609 VARIANT defkey
, subkey
, name
, value
, retval
;
610 IWbemClassObject
*sig
, *out_params
= NULL
;
613 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
615 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
616 if (hr
!= S_OK
) return hr
;
617 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
618 if (hr
!= S_OK
) return hr
;
619 hr
= IWbemClassObject_Get( in
, L
"sValueName", 0, &name
, NULL
, NULL
);
622 VariantClear( &subkey
);
625 hr
= IWbemClassObject_Get( in
, L
"sValue", 0, &value
, NULL
, NULL
);
628 VariantClear( &name
);
629 VariantClear( &subkey
);
633 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"SetStringValue", PARAM_OUT
, &sig
);
636 VariantClear( &name
);
637 VariantClear( &subkey
);
638 VariantClear( &value
);
643 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
646 VariantClear( &name
);
647 VariantClear( &subkey
);
648 VariantClear( &value
);
649 IWbemClassObject_Release( sig
);
654 set_stringvalue( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), V_BSTR(&name
), V_BSTR(&value
), context
, &retval
);
656 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
658 VariantClear( &name
);
659 VariantClear( &subkey
);
660 VariantClear( &value
);
661 IWbemClassObject_Release( sig
);
662 if (hr
== S_OK
&& out
)
665 IWbemClassObject_AddRef( out_params
);
667 if (out_params
) IWbemClassObject_Release( out_params
);
671 static void set_dwordvalue( HKEY root
, const WCHAR
*subkey
, const WCHAR
*name
, DWORD value
, IWbemContext
*context
,
677 TRACE( "%p, %s, %s, %#lx\n", root
, debugstr_w(subkey
), debugstr_w(name
), value
);
679 if ((res
= RegOpenKeyExW( root
, subkey
, 0, KEY_SET_VALUE
| get_access_mask( context
), &hkey
)))
681 set_variant( VT_UI4
, res
, NULL
, retval
);
685 res
= RegSetKeyValueW( hkey
, NULL
, name
, REG_DWORD
, &value
, sizeof(value
) );
686 set_variant( VT_UI4
, res
, NULL
, retval
);
690 HRESULT
reg_set_dwordvalue( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
692 VARIANT defkey
, subkey
, name
, value
, retval
;
693 IWbemClassObject
*sig
, *out_params
= NULL
;
696 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
698 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
699 if (hr
!= S_OK
) return hr
;
700 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
701 if (hr
!= S_OK
) return hr
;
702 hr
= IWbemClassObject_Get( in
, L
"sValueName", 0, &name
, NULL
, NULL
);
705 VariantClear( &subkey
);
708 hr
= IWbemClassObject_Get( in
, L
"uValue", 0, &value
, NULL
, NULL
);
711 VariantClear( &name
);
712 VariantClear( &subkey
);
716 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"SetDWORDValue", PARAM_OUT
, &sig
);
719 VariantClear( &name
);
720 VariantClear( &subkey
);
725 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
728 VariantClear( &name
);
729 VariantClear( &subkey
);
730 IWbemClassObject_Release( sig
);
734 set_dwordvalue( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), V_BSTR(&name
), V_UI4(&value
), context
, &retval
);
736 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
738 VariantClear( &name
);
739 VariantClear( &subkey
);
740 IWbemClassObject_Release( sig
);
741 if (hr
== S_OK
&& out
)
744 IWbemClassObject_AddRef( out_params
);
746 if (out_params
) IWbemClassObject_Release( out_params
);
750 static void delete_key( HKEY root
, const WCHAR
*subkey
, IWbemContext
*context
, VARIANT
*retval
)
754 TRACE("%p, %s\n", root
, debugstr_w(subkey
));
756 res
= RegDeleteKeyExW( root
, subkey
, get_access_mask( context
), 0 );
757 set_variant( VT_UI4
, res
, NULL
, retval
);
760 HRESULT
reg_delete_key( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
762 VARIANT defkey
, subkey
, retval
;
763 IWbemClassObject
*sig
, *out_params
= NULL
;
766 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
768 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
769 if (hr
!= S_OK
) return hr
;
770 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
771 if (hr
!= S_OK
) return hr
;
773 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"DeleteKey", PARAM_OUT
, &sig
);
776 VariantClear( &subkey
);
781 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
784 VariantClear( &subkey
);
785 IWbemClassObject_Release( sig
);
789 delete_key( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), context
, &retval
);
791 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
793 VariantClear( &subkey
);
794 IWbemClassObject_Release( sig
);
795 if (hr
== S_OK
&& out
)
798 IWbemClassObject_AddRef( out_params
);
800 if (out_params
) IWbemClassObject_Release( out_params
);