From 8a43d29ef494eca3a36c4202e494656982e47c1f Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mon, 22 Feb 2021 22:24:00 +1100 Subject: [PATCH] regedit/tests: Check for elevated privileges before cleaning up the Windows 3.1 test key and running unit tests. Signed-off-by: Hugh McMaster Signed-off-by: Alexandre Julliard --- programs/regedit/tests/regedit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/programs/regedit/tests/regedit.c b/programs/regedit/tests/regedit.c index 66b95624455..de4ddfa76a3 100644 --- a/programs/regedit/tests/regedit.c +++ b/programs/regedit/tests/regedit.c @@ -1094,15 +1094,12 @@ static void test_basic_import_unicode(void) static void test_basic_import_31(void) { HKEY hkey; + DWORD dispos; LONG lr; - lr = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE); - ok(lr == ERROR_SUCCESS || lr == ERROR_FILE_NOT_FOUND, - "RegDeleteKeyA failed: %d\n", lr); - /* Check if regedit.exe is running with elevated privileges */ lr = RegCreateKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_READ, NULL, &hkey, NULL); + KEY_READ|KEY_SET_VALUE, NULL, &hkey, &dispos); if (lr == ERROR_ACCESS_DENIED) { win_skip("regedit.exe is not running with elevated privileges; " @@ -1110,6 +1107,9 @@ static void test_basic_import_31(void) return; } + if (dispos == REG_OPENED_EXISTING_KEY) + delete_value(hkey, NULL); + /* Test simple value */ exec_import_str("REGEDIT\r\n" "HKEY_CLASSES_ROOT\\" KEY_BASE " = Value0\r\n");