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
) )))
189 return E_OUTOFMEMORY
;
193 if ((res
= RegEnumKeyW( hkey
, i
, buf
, len
)) == ERROR_NO_MORE_ITEMS
)
195 if (i
) res
= ERROR_SUCCESS
;
199 if (!(strings
[i
] = SysAllocString( buf
)))
201 for (i
--; i
>= 0; i
--) SysFreeString( strings
[i
] );
207 if (hr
== S_OK
&& !res
)
209 hr
= to_bstr_array( strings
, i
, names
);
210 free_bstr_array( strings
, i
);
212 set_variant( VT_UI4
, res
, NULL
, retval
);
218 HRESULT
reg_enum_key( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
220 VARIANT defkey
, subkey
, names
, retval
;
221 IWbemClassObject
*sig
, *out_params
= NULL
;
224 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
226 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
227 if (hr
!= S_OK
) return hr
;
228 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
229 if (hr
!= S_OK
) return hr
;
231 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"EnumKey", PARAM_OUT
, &sig
);
234 VariantClear( &subkey
);
239 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
242 VariantClear( &subkey
);
243 IWbemClassObject_Release( sig
);
247 VariantInit( &names
);
248 hr
= enum_key( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), &names
, context
, &retval
);
249 if (hr
!= S_OK
) goto done
;
252 if (!V_UI4( &retval
))
254 hr
= IWbemClassObject_Put( out_params
, L
"sNames", 0, &names
, CIM_STRING
|CIM_FLAG_ARRAY
);
255 if (hr
!= S_OK
) goto done
;
257 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
261 VariantClear( &names
);
262 VariantClear( &subkey
);
263 IWbemClassObject_Release( sig
);
264 if (hr
== S_OK
&& out
)
267 IWbemClassObject_AddRef( out_params
);
269 if (out_params
) IWbemClassObject_Release( out_params
);
273 static HRESULT
enum_values( HKEY root
, const WCHAR
*subkey
, VARIANT
*names
, VARIANT
*types
, IWbemContext
*context
,
278 BSTR
*value_names
= NULL
;
279 DWORD count
, buflen
, len
, *value_types
= NULL
;
283 TRACE("%p, %s\n", root
, debugstr_w(subkey
));
285 if ((res
= RegOpenKeyExW( root
, subkey
, 0, KEY_QUERY_VALUE
| get_access_mask( context
), &hkey
))) goto done
;
286 if ((res
= RegQueryInfoKeyW( hkey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &count
, &buflen
, NULL
, NULL
, NULL
)))
290 if (!(buf
= malloc( (buflen
+ 1) * sizeof(WCHAR
) ))) goto done
;
291 if (!(value_names
= malloc( count
* sizeof(BSTR
) ))) goto done
;
292 if (!(value_types
= malloc( count
* sizeof(DWORD
) ))) goto done
;
298 res
= RegEnumValueW( hkey
, i
, buf
, &len
, NULL
, &value_types
[i
], NULL
, NULL
);
299 if (res
== ERROR_NO_MORE_ITEMS
)
301 if (i
) res
= ERROR_SUCCESS
;
305 if (!(value_names
[i
] = SysAllocString( buf
)))
307 for (i
--; i
>= 0; i
--) SysFreeString( value_names
[i
] );
313 if (hr
== S_OK
&& !res
)
315 hr
= to_bstr_array( value_names
, i
, names
);
316 free_bstr_array( value_names
, i
);
317 if (hr
== S_OK
) hr
= to_i4_array( value_types
, i
, types
);
321 set_variant( VT_UI4
, res
, NULL
, retval
);
329 HRESULT
reg_enum_values( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
331 VARIANT defkey
, subkey
, names
, types
, retval
;
332 IWbemClassObject
*sig
, *out_params
= NULL
;
335 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
337 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
338 if (hr
!= S_OK
) return hr
;
339 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
340 if (hr
!= S_OK
) return hr
;
342 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"EnumValues", PARAM_OUT
, &sig
);
345 VariantClear( &subkey
);
350 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
353 VariantClear( &subkey
);
354 IWbemClassObject_Release( sig
);
358 VariantInit( &names
);
359 VariantInit( &types
);
360 hr
= enum_values( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), &names
, &types
, context
, &retval
);
361 if (hr
!= S_OK
) goto done
;
364 if (!V_UI4( &retval
))
366 hr
= IWbemClassObject_Put( out_params
, L
"sNames", 0, &names
, CIM_STRING
|CIM_FLAG_ARRAY
);
367 if (hr
!= S_OK
) goto done
;
368 hr
= IWbemClassObject_Put( out_params
, L
"Types", 0, &types
, CIM_SINT32
|CIM_FLAG_ARRAY
);
369 if (hr
!= S_OK
) goto done
;
371 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
375 VariantClear( &types
);
376 VariantClear( &names
);
377 VariantClear( &subkey
);
378 IWbemClassObject_Release( sig
);
379 if (hr
== S_OK
&& out
)
382 IWbemClassObject_AddRef( out_params
);
384 if (out_params
) IWbemClassObject_Release( out_params
);
388 static HRESULT
get_stringvalue( HKEY root
, const WCHAR
*subkey
, const WCHAR
*name
, VARIANT
*value
,
389 IWbemContext
*context
, VARIANT
*retval
)
391 DWORD size
, mask
, flags
= RRF_RT_REG_SZ
;
396 TRACE("%p, %s, %s\n", root
, debugstr_w(subkey
), debugstr_w(name
));
398 mask
= get_access_mask( context
);
400 if (mask
& KEY_WOW64_64KEY
)
401 flags
|= RRF_SUBKEY_WOW6464KEY
;
402 else if (mask
& KEY_WOW64_32KEY
)
403 flags
|= RRF_SUBKEY_WOW6432KEY
;
405 if ((res
= RegGetValueW( root
, subkey
, name
, flags
, NULL
, NULL
, &size
))) goto done
;
406 if (!(str
= SysAllocStringLen( NULL
, size
/ sizeof(WCHAR
) - 1 ))) return E_OUTOFMEMORY
;
407 if (!(res
= RegGetValueW( root
, subkey
, name
, flags
, NULL
, str
, &size
))) set_variant( VT_BSTR
, 0, str
, value
);
410 set_variant( VT_UI4
, res
, NULL
, retval
);
411 if (res
) SysFreeString( str
);
415 HRESULT
reg_get_stringvalue( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
417 VARIANT defkey
, subkey
, name
, value
, retval
;
418 IWbemClassObject
*sig
, *out_params
= NULL
;
421 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
423 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
424 if (hr
!= S_OK
) return hr
;
425 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
426 if (hr
!= S_OK
) return hr
;
427 hr
= IWbemClassObject_Get( in
, L
"sValueName", 0, &name
, NULL
, NULL
);
430 VariantClear( &subkey
);
434 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"GetStringValue", PARAM_OUT
, &sig
);
437 VariantClear( &name
);
438 VariantClear( &subkey
);
443 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
446 VariantClear( &name
);
447 VariantClear( &subkey
);
448 IWbemClassObject_Release( sig
);
452 VariantInit( &value
);
453 hr
= get_stringvalue( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), V_BSTR(&name
), &value
, context
, &retval
);
454 if (hr
!= S_OK
) goto done
;
457 if (!V_UI4( &retval
))
459 hr
= IWbemClassObject_Put( out_params
, L
"sValue", 0, &value
, CIM_STRING
);
460 if (hr
!= S_OK
) goto done
;
462 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
466 VariantClear( &name
);
467 VariantClear( &subkey
);
468 IWbemClassObject_Release( sig
);
469 if (hr
== S_OK
&& out
)
472 IWbemClassObject_AddRef( out_params
);
474 if (out_params
) IWbemClassObject_Release( out_params
);
478 static HRESULT
to_ui1_array( BYTE
*value
, DWORD size
, VARIANT
*var
)
484 if (!(sa
= SafeArrayCreateVector( VT_UI1
, 0, size
))) return E_OUTOFMEMORY
;
485 for (i
= 0; i
< size
; i
++)
487 if ((hr
= SafeArrayPutElement( sa
, &i
, &value
[i
] )) != S_OK
)
489 SafeArrayDestroy( sa
);
493 set_variant( VT_UI1
|VT_ARRAY
, 0, sa
, var
);
497 static HRESULT
get_binaryvalue( HKEY root
, const WCHAR
*subkey
, const WCHAR
*name
, VARIANT
*value
,
498 IWbemContext
*context
, VARIANT
*retval
)
500 DWORD size
, mask
, flags
= RRF_RT_REG_BINARY
;
505 TRACE("%p, %s, %s\n", root
, debugstr_w(subkey
), debugstr_w(name
));
507 mask
= get_access_mask( context
);
509 if (mask
& KEY_WOW64_64KEY
)
510 flags
|= RRF_SUBKEY_WOW6464KEY
;
511 else if (mask
& KEY_WOW64_32KEY
)
512 flags
|= RRF_SUBKEY_WOW6432KEY
;
514 if ((res
= RegGetValueW( root
, subkey
, name
, flags
, NULL
, NULL
, &size
))) goto done
;
515 if (!(buf
= malloc( size
))) return E_OUTOFMEMORY
;
516 if (!(res
= RegGetValueW( root
, subkey
, name
, flags
, NULL
, buf
, &size
))) hr
= to_ui1_array( buf
, size
, value
);
519 set_variant( VT_UI4
, res
, NULL
, retval
);
524 HRESULT
reg_get_binaryvalue( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
526 VARIANT defkey
, subkey
, name
, value
, retval
;
527 IWbemClassObject
*sig
, *out_params
= NULL
;
530 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
532 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
533 if (hr
!= S_OK
) return hr
;
534 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
535 if (hr
!= S_OK
) return hr
;
536 hr
= IWbemClassObject_Get( in
, L
"sValueName", 0, &name
, NULL
, NULL
);
539 VariantClear( &subkey
);
543 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"GetBinaryValue", PARAM_OUT
, &sig
);
546 VariantClear( &name
);
547 VariantClear( &subkey
);
552 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
555 VariantClear( &name
);
556 VariantClear( &subkey
);
557 IWbemClassObject_Release( sig
);
561 VariantInit( &value
);
562 hr
= get_binaryvalue( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), V_BSTR(&name
), &value
, context
, &retval
);
563 if (hr
!= S_OK
) goto done
;
566 if (!V_UI4( &retval
))
568 hr
= IWbemClassObject_Put( out_params
, L
"uValue", 0, &value
, CIM_UINT8
|CIM_FLAG_ARRAY
);
569 if (hr
!= S_OK
) goto done
;
571 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
575 VariantClear( &name
);
576 VariantClear( &subkey
);
577 IWbemClassObject_Release( sig
);
578 if (hr
== S_OK
&& out
)
581 IWbemClassObject_AddRef( out_params
);
583 if (out_params
) IWbemClassObject_Release( out_params
);
587 static void set_stringvalue( HKEY root
, const WCHAR
*subkey
, const WCHAR
*name
, const WCHAR
*value
,
588 IWbemContext
*context
, VARIANT
*retval
)
593 TRACE("%p, %s, %s, %s\n", root
, debugstr_w(subkey
), debugstr_w(name
), debugstr_w(value
));
595 if ((res
= RegOpenKeyExW( root
, subkey
, 0, KEY_SET_VALUE
| get_access_mask( context
), &hkey
)))
597 set_variant( VT_UI4
, res
, NULL
, retval
);
601 res
= RegSetKeyValueW( hkey
, NULL
, name
, REG_SZ
, value
, (lstrlenW( value
) + 1) * sizeof(*value
) );
602 set_variant( VT_UI4
, res
, NULL
, retval
);
606 HRESULT
reg_set_stringvalue( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
608 VARIANT defkey
, subkey
, name
, value
, retval
;
609 IWbemClassObject
*sig
, *out_params
= NULL
;
612 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
614 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
615 if (hr
!= S_OK
) return hr
;
616 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
617 if (hr
!= S_OK
) return hr
;
618 hr
= IWbemClassObject_Get( in
, L
"sValueName", 0, &name
, NULL
, NULL
);
621 VariantClear( &subkey
);
624 hr
= IWbemClassObject_Get( in
, L
"sValue", 0, &value
, NULL
, NULL
);
627 VariantClear( &name
);
628 VariantClear( &subkey
);
632 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"SetStringValue", PARAM_OUT
, &sig
);
635 VariantClear( &name
);
636 VariantClear( &subkey
);
637 VariantClear( &value
);
642 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
645 VariantClear( &name
);
646 VariantClear( &subkey
);
647 VariantClear( &value
);
648 IWbemClassObject_Release( sig
);
653 set_stringvalue( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), V_BSTR(&name
), V_BSTR(&value
), context
, &retval
);
655 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
657 VariantClear( &name
);
658 VariantClear( &subkey
);
659 VariantClear( &value
);
660 IWbemClassObject_Release( sig
);
661 if (hr
== S_OK
&& out
)
664 IWbemClassObject_AddRef( out_params
);
666 if (out_params
) IWbemClassObject_Release( out_params
);
670 static void set_dwordvalue( HKEY root
, const WCHAR
*subkey
, const WCHAR
*name
, DWORD value
, IWbemContext
*context
,
676 TRACE( "%p, %s, %s, %#lx\n", root
, debugstr_w(subkey
), debugstr_w(name
), value
);
678 if ((res
= RegOpenKeyExW( root
, subkey
, 0, KEY_SET_VALUE
| get_access_mask( context
), &hkey
)))
680 set_variant( VT_UI4
, res
, NULL
, retval
);
684 res
= RegSetKeyValueW( hkey
, NULL
, name
, REG_DWORD
, &value
, sizeof(value
) );
685 set_variant( VT_UI4
, res
, NULL
, retval
);
689 HRESULT
reg_set_dwordvalue( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
691 VARIANT defkey
, subkey
, name
, value
, retval
;
692 IWbemClassObject
*sig
, *out_params
= NULL
;
695 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
697 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
698 if (hr
!= S_OK
) return hr
;
699 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
700 if (hr
!= S_OK
) return hr
;
701 hr
= IWbemClassObject_Get( in
, L
"sValueName", 0, &name
, NULL
, NULL
);
704 VariantClear( &subkey
);
707 hr
= IWbemClassObject_Get( in
, L
"uValue", 0, &value
, NULL
, NULL
);
710 VariantClear( &name
);
711 VariantClear( &subkey
);
715 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"SetDWORDValue", PARAM_OUT
, &sig
);
718 VariantClear( &name
);
719 VariantClear( &subkey
);
724 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
727 VariantClear( &name
);
728 VariantClear( &subkey
);
729 IWbemClassObject_Release( sig
);
733 set_dwordvalue( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), V_BSTR(&name
), V_UI4(&value
), context
, &retval
);
735 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
737 VariantClear( &name
);
738 VariantClear( &subkey
);
739 IWbemClassObject_Release( sig
);
740 if (hr
== S_OK
&& out
)
743 IWbemClassObject_AddRef( out_params
);
745 if (out_params
) IWbemClassObject_Release( out_params
);
749 static void delete_key( HKEY root
, const WCHAR
*subkey
, IWbemContext
*context
, VARIANT
*retval
)
753 TRACE("%p, %s\n", root
, debugstr_w(subkey
));
755 res
= RegDeleteKeyExW( root
, subkey
, get_access_mask( context
), 0 );
756 set_variant( VT_UI4
, res
, NULL
, retval
);
759 HRESULT
reg_delete_key( IWbemClassObject
*obj
, IWbemContext
*context
, IWbemClassObject
*in
, IWbemClassObject
**out
)
761 VARIANT defkey
, subkey
, retval
;
762 IWbemClassObject
*sig
, *out_params
= NULL
;
765 TRACE("%p, %p, %p, %p\n", obj
, context
, in
, out
);
767 hr
= IWbemClassObject_Get( in
, L
"hDefKey", 0, &defkey
, NULL
, NULL
);
768 if (hr
!= S_OK
) return hr
;
769 hr
= IWbemClassObject_Get( in
, L
"sSubKeyName", 0, &subkey
, NULL
, NULL
);
770 if (hr
!= S_OK
) return hr
;
772 hr
= create_signature( WBEMPROX_NAMESPACE_CIMV2
, L
"StdRegProv", L
"DeleteKey", PARAM_OUT
, &sig
);
775 VariantClear( &subkey
);
780 hr
= IWbemClassObject_SpawnInstance( sig
, 0, &out_params
);
783 VariantClear( &subkey
);
784 IWbemClassObject_Release( sig
);
788 delete_key( (HKEY
)(INT_PTR
)V_I4(&defkey
), V_BSTR(&subkey
), context
, &retval
);
790 hr
= IWbemClassObject_Put( out_params
, L
"ReturnValue", 0, &retval
, CIM_UINT32
);
792 VariantClear( &subkey
);
793 IWbemClassObject_Release( sig
);
794 if (hr
== S_OK
&& out
)
797 IWbemClassObject_AddRef( out_params
);
799 if (out_params
) IWbemClassObject_Release( out_params
);