Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
3f3e2925
Commit
3f3e2925
authored
Oct 14, 2004
by
Bill Medland
Committed by
Alexandre Julliard
Oct 14, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SHDeleteKey so that it will handle deleting a key with more than
one subkey. Also includes test.
parent
5ec458fd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
7 deletions
+44
-7
reg.c
dlls/shlwapi/reg.c
+8
-7
shreg.c
dlls/shlwapi/tests/shreg.c
+36
-0
No files found.
dlls/shlwapi/reg.c
View file @
3f3e2925
...
...
@@ -1298,7 +1298,7 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue,
*/
DWORD
WINAPI
SHDeleteKeyA
(
HKEY
hKey
,
LPCSTR
lpszSubKey
)
{
DWORD
dwRet
,
dw
KeyCount
=
0
,
dwMaxSubkeyLen
=
0
,
dwSize
,
i
;
DWORD
dwRet
,
dw
MaxSubkeyLen
=
0
,
dwSize
;
CHAR
szNameBuf
[
MAX_PATH
],
*
lpszName
=
szNameBuf
;
HKEY
hSubKey
=
0
;
...
...
@@ -1307,8 +1307,8 @@ DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey)
dwRet
=
RegOpenKeyExA
(
hKey
,
lpszSubKey
,
0
,
KEY_READ
,
&
hSubKey
);
if
(
!
dwRet
)
{
/* Find
how many subkeys there are
*/
dwRet
=
RegQueryInfoKeyA
(
hSubKey
,
NULL
,
NULL
,
NULL
,
&
dwKeyCount
,
/* Find
the maximum subkey length so that we can allocate a buffer
*/
dwRet
=
RegQueryInfoKeyA
(
hSubKey
,
NULL
,
NULL
,
NULL
,
NULL
,
&
dwMaxSubkeyLen
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
!
dwRet
)
{
...
...
@@ -1321,14 +1321,15 @@ DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey)
dwRet
=
ERROR_NOT_ENOUGH_MEMORY
;
else
{
/* Recursively delete all the subkeys */
for
(
i
=
0
;
i
<
dwKeyCount
&&
!
dwRet
;
i
++
)
while
(
dwRet
==
ERROR_SUCCESS
)
{
dwSize
=
dwMaxSubkeyLen
;
dwRet
=
RegEnumKeyExA
(
hSubKey
,
i
,
lpszName
,
&
dwSize
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
!
dwRet
)
dwRet
=
RegEnumKeyExA
(
hSubKey
,
0
,
lpszName
,
&
dwSize
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
dwRet
==
ERROR_SUCCESS
||
dwRet
==
ERROR_MORE_DATA
)
dwRet
=
SHDeleteKeyA
(
hSubKey
,
lpszName
);
}
if
(
dwRet
==
ERROR_NO_MORE_ITEMS
)
dwRet
=
ERROR_SUCCESS
;
if
(
lpszName
!=
szNameBuf
)
HeapFree
(
GetProcessHeap
(),
0
,
lpszName
);
/* Free buffer if allocated */
}
...
...
dlls/shlwapi/tests/shreg.c
View file @
3f3e2925
...
...
@@ -271,6 +271,41 @@ static void test_SHCopyKey(void)
RegCloseKey
(
hKeyDst
);
}
static
void
test_SHDeleteKey
()
{
HKEY
hKeyTest
;
int
sysfail
=
1
;
if
(
!
RegOpenKeyA
(
HKEY_CURRENT_USER
,
REG_TEST_KEY
,
&
hKeyTest
))
{
HKEY
hKeyS
;
if
(
!
RegCreateKey
(
hKeyTest
,
"ODBC"
,
&
hKeyS
))
{
HKEY
hKeyO
;
if
(
!
RegCreateKey
(
hKeyS
,
"ODBC.INI"
,
&
hKeyO
))
{
RegCloseKey
(
hKeyO
);
if
(
!
RegCreateKey
(
hKeyS
,
"ODBCINST.INI"
,
&
hKeyO
))
{
RegCloseKey
(
hKeyO
);
sysfail
=
0
;
}
}
RegCloseKey
(
hKeyS
);
}
RegCloseKey
(
hKeyTest
);
}
if
(
!
sysfail
)
{
HKEY
hKeyS
;
DWORD
dwRet
;
ok
(
!
SHDeleteKey
(
HKEY_CURRENT_USER
,
REG_TEST_KEY
"
\\
ODBC"
),
"SHDeleteKey failed
\n
"
);
ok
((
dwRet
=
RegOpenKey
(
HKEY_CURRENT_USER
,
REG_TEST_KEY
"
\\
ODBC"
,
&
hKeyS
))
==
ERROR_FILE_NOT_FOUND
,
"SHDeleteKey did not delete
\n
"
);
if
(
dwRet
==
ERROR_SUCCESS
)
RegCloseKey
(
hKeyS
);
}
else
ok
(
0
,
"Could not set up SHDeleteKey test
\n
"
);
}
START_TEST
(
shreg
)
{
...
...
@@ -285,5 +320,6 @@ START_TEST(shreg)
test_SHQUeryValueEx
();
test_SHGetRegPath
();
test_SHCopyKey
();
test_SHDeleteKey
();
delete_key
(
hkey
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment