Module: wine Branch: master Commit: 9ea45b5a2e26ff64b94a52eb862b2838a13cdc42 URL: https://gitlab.winehq.org/wine/wine/-/commit/9ea45b5a2e26ff64b94a52eb862b283...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Wed Sep 22 19:01:44 2021 +1000
sapi: Implement ISpObjectToken OpenKey.
---
dlls/sapi/tests/token.c | 8 ++++++++ dlls/sapi/token.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/dlls/sapi/tests/token.c b/dlls/sapi/tests/token.c index 7778f4e61db..7ef58e697b0 100644 --- a/dlls/sapi/tests/token.c +++ b/dlls/sapi/tests/token.c @@ -194,6 +194,7 @@ static void test_default_token_id(void) static void test_object_token(void) { ISpObjectToken *token; + ISpDataKey *sub_key; HRESULT hr; LPWSTR tempW, token_id; ISpObjectTokenCategory *cat; @@ -253,6 +254,13 @@ static void test_object_token(void) CoTaskMemFree( tempW ); }
+ hr = ISpObjectToken_OpenKey(token, L"Non-exist", &sub_key); + ok( hr == SPERR_NOT_FOUND, "got %08lx\n", hr ); + + hr = ISpObjectToken_OpenKey(token, L"Classes", &sub_key); + ok( hr == S_OK, "got %08lx\n", hr ); + ISpDataKey_Release(sub_key); + cat = (LPVOID)0xdeadbeef; hr = ISpObjectToken_GetCategory( token, &cat ); todo_wine ok( hr == SPERR_INVALID_REGISTRY_KEY, "got %08lx\n", hr ); diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index b5cfc45e5a3..476e8d6d248 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -931,8 +931,37 @@ 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 SPERR_NOT_FOUND; + + hr = data_key_create(NULL, &IID_ISpRegDataKey, (void**)&spregkey); + if (FAILED(hr)) + { + RegCloseKey(key); + return hr; + } + + hr = ISpRegDataKey_SetKey(spregkey, key, FALSE); + if (FAILED(hr)) + { + RegCloseKey(key); + ISpRegDataKey_Release(spregkey); + return hr; + } + + hr = ISpRegDataKey_QueryInterface(spregkey, &IID_ISpDataKey, (void**)sub_key); + ISpRegDataKey_Release(spregkey); + + return hr; }
static HRESULT WINAPI token_CreateKey( ISpObjectToken *iface,