From 26a5401b90c60a267646975321a7a25126fc165c Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 22 Sep 2021 19:01:44 +1000 Subject: [PATCH 7/8] sapi: Implement ISpObjectToken OpenKey --- dlls/sapi/token.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index 4b9ca15fe11..06f1250a40b 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -982,8 +982,29 @@ static HRESULT WINAPI token_GetDWORD( ISpObjectToken *iface, static HRESULT WINAPI token_OpenKey( ISpObjectToken *iface, LPCWSTR name, ISpDataKey **sub_key ) { - FIXME( "stub\n" ); - return E_NOTIMPL; + struct object_token *This = impl_from_ISpObjectToken( iface ); + ISpRegDataKey *spregkey; + HRESULT hr; + HKEY key; + LONG ret; + + TRACE( "%p, %s, %p\n", This, debugstr_w(name), sub_key ); + + ret = RegOpenKeyExW (This->token_key, name, 0, KEY_ALL_ACCESS, &key); + if (ret != ERROR_SUCCESS) + return HRESULT_FROM_WIN32(ret); + + hr = data_key_create(NULL, &IID_ISpRegDataKey, (void**)&spregkey); + if (hr == S_OK) + { + hr = ISpRegDataKey_SetKey(spregkey, key, FALSE); + if (hr == S_OK) + { + hr = ISpRegDataKey_QueryInterface(spregkey, &IID_ISpDataKey, (void**)sub_key); + ISpRegDataKey_Release(spregkey); + } + } + return hr; } static HRESULT WINAPI token_CreateKey( ISpObjectToken *iface, -- 2.33.0