From 6053d265bcddb813a891c797b42a36d5bde6223f Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Sat, 8 Apr 2006 01:03:30 -0500 Subject: [PATCH] advpack: Add initial implementation of SetPerUserSecValues. --- dlls/advpack/advpack.c | 75 +++++++++++++++++++++++++++++++++++++++++--- dlls/advpack/tests/advpack.c | 59 ++++++++++++++-------------------- 2 files changed, 94 insertions(+), 40 deletions(-) diff --git a/dlls/advpack/advpack.c b/dlls/advpack/advpack.c index da86f7561ce..e9fbc076ec5 100644 --- a/dlls/advpack/advpack.c +++ b/dlls/advpack/advpack.c @@ -469,15 +469,80 @@ HRESULT WINAPI SetPerUserSecValuesA(PERUSERSECTIONA* pPerUser) * RETURNS * Success: S_OK. * Failure: E_FAIL. - * - * BUGS - * Unimplemented. */ HRESULT WINAPI SetPerUserSecValuesW(PERUSERSECTIONW* pPerUser) { - FIXME("(%p) stub\n", pPerUser); + HKEY setup, guid; + + static const WCHAR setup_key[] = { + 'S','O','F','T','W','A','R','E','\\', + 'M','i','c','r','o','s','o','f','t','\\', + 'A','c','t','i','v','e',' ','S','e','t','u','p','\\', + 'I','n','s','t','a','l','l','e','d',' ', + 'C','o','m','p','o','n','e','n','t','s',0 + }; - return E_FAIL; + static const WCHAR stub_path[] = {'S','t','u','b','P','a','t','h',0}; + static const WCHAR version[] = {'V','e','r','s','i','o','n',0}; + static const WCHAR locale[] = {'L','o','c','a','l','e',0}; + static const WCHAR compid[] = {'C','o','m','p','o','n','e','n','t','I','D',0}; + static const WCHAR isinstalled[] = {'I','s','I','n','s','t','a','l','l','e','d',0}; + + TRACE("(%p)\n", pPerUser); + + if (!pPerUser || !*pPerUser->szGUID) + return S_OK; + + if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, setup_key, 0, NULL, 0, KEY_WRITE, + NULL, &setup, NULL)) + { + return E_FAIL; + } + + if (RegCreateKeyExW(setup, pPerUser->szGUID, 0, NULL, 0, KEY_ALL_ACCESS, + NULL, &guid, NULL)) + { + RegCloseKey(setup); + return E_FAIL; + } + + if (*pPerUser->szStub) + { + RegSetValueExW(guid, stub_path, 0, REG_SZ, (LPBYTE)pPerUser->szStub, + (lstrlenW(pPerUser->szStub) + 1) * sizeof(WCHAR)); + } + + if (*pPerUser->szVersion) + { + RegSetValueExW(guid, version, 0, REG_SZ, (LPBYTE)pPerUser->szVersion, + (lstrlenW(pPerUser->szVersion) + 1) * sizeof(WCHAR)); + } + + if (*pPerUser->szLocale) + { + RegSetValueExW(guid, locale, 0, REG_SZ, (LPBYTE)pPerUser->szLocale, + (lstrlenW(pPerUser->szLocale) + 1) * sizeof(WCHAR)); + } + + if (*pPerUser->szCompID) + { + RegSetValueExW(guid, compid, 0, REG_SZ, (LPBYTE)pPerUser->szCompID, + (lstrlenW(pPerUser->szCompID) + 1) * sizeof(WCHAR)); + } + + if (*pPerUser->szDispName) + { + RegSetValueExW(guid, NULL, 0, REG_SZ, (LPBYTE)pPerUser->szDispName, + (lstrlenW(pPerUser->szDispName) + 1) * sizeof(WCHAR)); + } + + RegSetValueExW(guid, isinstalled, 0, REG_DWORD, + (LPBYTE)&pPerUser->dwIsInstalled, sizeof(DWORD)); + + RegCloseKey(guid); + RegCloseKey(setup); + + return S_OK; } /*********************************************************************** diff --git a/dlls/advpack/tests/advpack.c b/dlls/advpack/tests/advpack.c index 0ff8bb93a70..a79f9245469 100644 --- a/dlls/advpack/tests/advpack.c +++ b/dlls/advpack/tests/advpack.c @@ -436,34 +436,26 @@ static void setperusersecvalues_test() /* try a NULL pPerUser */ hr = pSetPerUserSecValues(NULL); todo_wine - { - ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); - } + ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); ok(!OPEN_GUID_KEY(), "Expected guid key to not exist\n"); /* at the very least, szGUID must be valid */ peruser.szGUID[0] = '\0'; hr = pSetPerUserSecValues(&peruser); - todo_wine - { - ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); - } + ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); ok(!OPEN_GUID_KEY(), "Expected guid key to not exist\n"); /* set initial values */ lstrcpy(peruser.szGUID, "guid"); hr = pSetPerUserSecValues(&peruser); - todo_wine - { - ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); - ok(OPEN_GUID_KEY(), "Expected guid key to exist\n"); - ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n"); - ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n"); - ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n"); - ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n"); - ok(check_reg_str(guid, "Version", "1,1,1,1"), "Expected 1,1,1,1\n"); - ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n"); - } + ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); + ok(OPEN_GUID_KEY(), "Expected guid key to exist\n"); + ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n"); + ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n"); + ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n"); + ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n"); + ok(check_reg_str(guid, "Version", "1,1,1,1"), "Expected 1,1,1,1\n"); + ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n"); ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n"); @@ -473,16 +465,13 @@ static void setperusersecvalues_test() /* raise the version, but bRollback is FALSE, so vals not saved */ lstrcpy(peruser.szVersion, "2,1,1,1"); hr = pSetPerUserSecValues(&peruser); - todo_wine - { - ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); - ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n"); - ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n"); - ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n"); - ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n"); - ok(check_reg_str(guid, "Version", "2,1,1,1"), "Expected 2,1,1,1\n"); - ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n"); - } + ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); + ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n"); + ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n"); + ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n"); + ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n"); + ok(check_reg_str(guid, "Version", "2,1,1,1"), "Expected 2,1,1,1\n"); + ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n"); ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n"); @@ -490,16 +479,17 @@ static void setperusersecvalues_test() ok(!REG_VAL_EXISTS(guid, "RealStubPath"), "Expected RealStubPath to not exist\n"); /* raise the version again, bRollback is TRUE so vals are saved */ - peruser.bRollback = 1; + peruser.bRollback = TRUE; lstrcpy(peruser.szVersion, "3,1,1,1"); hr = pSetPerUserSecValues(&peruser); + ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); + ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n"); + ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n"); + ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n"); + ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n"); + ok(check_reg_str(guid, "Version", "3,1,1,1"), "Expected 3,1,1,1\n"); todo_wine { - ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); - ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n"); - ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n"); - ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n"); - ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n"); ok(check_reg_str(guid, "OldDisplayName", "displayname"), "Expected displayname\n"); ok(check_reg_str(guid, "OldLocale", "locale"), "Expected locale\n"); ok(check_reg_str(guid, "RealStubPath", "stub"), "Expected stub\n"); @@ -508,7 +498,6 @@ static void setperusersecvalues_test() ok(check_reg_str(guid, "StubPath", "rundll32.exe advpack.dll,UserInstStubWrapper guid"), "Expected real stub\n"); - ok(check_reg_str(guid, "Version", "3,1,1,1"), "Expected 3,1,1,1\n"); } RegDeleteKey(HKEY_LOCAL_MACHINE, GUID_KEY); -- 2.11.4.GIT