sapi: Implement ISpObjectToken OpenKey.

This commit is contained in:
Alistair Leslie-Hughes 2021-09-22 19:01:44 +10:00 committed by Alexandre Julliard
parent e58052d836
commit 9ea45b5a2e
2 changed files with 39 additions and 2 deletions

View file

@ -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 );

View file

@ -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,