Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
38faec25
Commit
38faec25
authored
Nov 29, 2018
by
Nikolay Sivov
Committed by
Alexandre Julliard
Nov 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shcore: Add some registry key delete helpers.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a88f66d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
141 additions
and
6 deletions
+141
-6
main.c
dlls/shcore/main.c
+110
-0
shcore.spec
dlls/shcore/shcore.spec
+6
-6
shcore.c
dlls/shcore/tests/shcore.c
+25
-0
No files found.
dlls/shcore/main.c
View file @
38faec25
...
...
@@ -1763,3 +1763,113 @@ HKEY WINAPI SHRegDuplicateHKey(HKEY hKey)
TRACE
(
"new key is %p
\n
"
,
newKey
);
return
newKey
;
}
/*************************************************************************
* SHDeleteEmptyKeyW [SHCORE.@]
*/
DWORD
WINAPI
SHDeleteEmptyKeyW
(
HKEY
hkey
,
const
WCHAR
*
subkey
)
{
DWORD
ret
,
count
=
0
;
HKEY
hsubkey
=
0
;
TRACE
(
"(%p, %s)
\n
"
,
hkey
,
debugstr_w
(
subkey
));
ret
=
RegOpenKeyExW
(
hkey
,
subkey
,
0
,
KEY_READ
,
&
hsubkey
);
if
(
!
ret
)
{
ret
=
RegQueryInfoKeyW
(
hsubkey
,
NULL
,
NULL
,
NULL
,
&
count
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
RegCloseKey
(
hsubkey
);
if
(
!
ret
)
{
if
(
count
)
ret
=
ERROR_KEY_HAS_CHILDREN
;
else
ret
=
RegDeleteKeyW
(
hkey
,
subkey
);
}
}
return
ret
;
}
/*************************************************************************
* SHDeleteEmptyKeyA [SHCORE.@]
*/
DWORD
WINAPI
SHDeleteEmptyKeyA
(
HKEY
hkey
,
const
char
*
subkey
)
{
WCHAR
*
subkeyW
=
NULL
;
DWORD
ret
;
TRACE
(
"(%p, %s)
\n
"
,
hkey
,
debugstr_a
(
subkey
));
if
(
subkey
&&
FAILED
(
SHStrDupA
(
subkey
,
&
subkeyW
)))
return
ERROR_OUTOFMEMORY
;
ret
=
SHDeleteEmptyKeyW
(
hkey
,
subkeyW
);
CoTaskMemFree
(
subkeyW
);
return
ret
;
}
/*************************************************************************
* SHDeleteKeyW [SHCORE.@]
*/
DWORD
WINAPI
SHDeleteKeyW
(
HKEY
hkey
,
const
WCHAR
*
subkey
)
{
TRACE
(
"(%p, %s)
\n
"
,
hkey
,
debugstr_w
(
subkey
));
return
RegDeleteTreeW
(
hkey
,
subkey
);
}
/*************************************************************************
* SHDeleteKeyA [SHCORE.@]
*/
DWORD
WINAPI
SHDeleteKeyA
(
HKEY
hkey
,
const
char
*
subkey
)
{
TRACE
(
"(%p, %s)
\n
"
,
hkey
,
debugstr_a
(
subkey
));
return
RegDeleteTreeA
(
hkey
,
subkey
);
}
/*************************************************************************
* SHDeleteValueW [SHCORE.@]
*/
DWORD
WINAPI
SHDeleteValueW
(
HKEY
hkey
,
const
WCHAR
*
subkey
,
const
WCHAR
*
value
)
{
HKEY
hsubkey
;
DWORD
ret
;
TRACE
(
"(%p, %s, %s)
\n
"
,
hkey
,
debugstr_w
(
subkey
),
debugstr_w
(
value
));
ret
=
RegOpenKeyExW
(
hkey
,
subkey
,
0
,
KEY_SET_VALUE
,
&
hsubkey
);
if
(
!
ret
)
{
ret
=
RegDeleteValueW
(
hsubkey
,
value
);
RegCloseKey
(
hsubkey
);
}
return
ret
;
}
/*************************************************************************
* SHDeleteValueA [SHCORE.@]
*/
DWORD
WINAPI
SHDeleteValueA
(
HKEY
hkey
,
const
char
*
subkey
,
const
char
*
value
)
{
WCHAR
*
subkeyW
=
NULL
,
*
valueW
=
NULL
;
DWORD
ret
;
TRACE
(
"(%p, %s, %s)
\n
"
,
hkey
,
debugstr_a
(
subkey
),
debugstr_a
(
value
));
if
(
subkey
&&
FAILED
(
SHStrDupA
(
subkey
,
&
subkeyW
)))
return
ERROR_OUTOFMEMORY
;
if
(
value
&&
FAILED
(
SHStrDupA
(
value
,
&
valueW
)))
{
CoTaskMemFree
(
subkeyW
);
return
ERROR_OUTOFMEMORY
;
}
ret
=
SHDeleteValueW
(
hkey
,
subkeyW
,
valueW
);
CoTaskMemFree
(
subkeyW
);
CoTaskMemFree
(
valueW
);
return
ret
;
}
dlls/shcore/shcore.spec
View file @
38faec25
...
...
@@ -40,12 +40,12 @@
@ stdcall SHCreateThread(ptr ptr long ptr)
@ stdcall SHCreateThreadRef(ptr ptr)
@ stub SHCreateThreadWithHandle
@ stdcall SHDeleteEmptyKeyA(long ptr)
shlwapi.SHDeleteEmptyKeyA
@ stdcall SHDeleteEmptyKeyW(long ptr)
shlwapi.SHDeleteEmptyKeyW
@ stdcall SHDeleteKeyA(long str)
shlwapi.SHDeleteKeyA
@ stdcall SHDeleteKeyW(long wstr)
shlwapi.SHDeleteKeyW
@ stdcall SHDeleteValueA(long
str str) shlwapi.SHDeleteValueA
@ stdcall SHDeleteValueW(long wstr wstr)
shlwapi.SHDeleteValueW
@ stdcall SHDeleteEmptyKeyA(long ptr)
@ stdcall SHDeleteEmptyKeyW(long ptr)
@ stdcall SHDeleteKeyA(long str)
@ stdcall SHDeleteKeyW(long wstr)
@ stdcall SHDeleteValueA(long
str str)
@ stdcall SHDeleteValueW(long wstr wstr)
@ stdcall SHEnumKeyExA(long long str ptr) shlwapi.SHEnumKeyExA
@ stdcall SHEnumKeyExW(long long wstr ptr) shlwapi.SHEnumKeyExW
@ stdcall SHEnumValueA(long long str ptr ptr ptr ptr) shlwapi.SHEnumValueA
...
...
dlls/shcore/tests/shcore.c
View file @
38faec25
...
...
@@ -34,6 +34,7 @@ static int (WINAPI *pSHAnsiToUnicode)(const char *, WCHAR *, int);
static
int
(
WINAPI
*
pSHAnsiToAnsi
)(
const
char
*
,
char
*
,
int
);
static
int
(
WINAPI
*
pSHUnicodeToUnicode
)(
const
WCHAR
*
,
WCHAR
*
,
int
);
static
HKEY
(
WINAPI
*
pSHRegDuplicateHKey
)(
HKEY
);
static
DWORD
(
WINAPI
*
pSHDeleteKeyA
)(
HKEY
,
const
char
*
);
static
void
init
(
HMODULE
hshcore
)
{
...
...
@@ -45,6 +46,7 @@ static void init(HMODULE hshcore)
X
(
SHAnsiToAnsi
);
X
(
SHUnicodeToUnicode
);
X
(
SHRegDuplicateHKey
);
X
(
SHDeleteKeyA
);
#undef X
}
...
...
@@ -319,6 +321,28 @@ static void test_SHRegDuplicateHKey(void)
RegDeleteKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Test"
);
}
static
void
test_SHDeleteKey
(
void
)
{
HKEY
hkey
,
hkey2
;
DWORD
ret
;
ret
=
RegCreateKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Test"
,
&
hkey
);
ok
(
!
ret
,
"Failed to create test key, %d.
\n
"
,
ret
);
ret
=
RegCreateKeyA
(
hkey
,
"delete_key"
,
&
hkey2
);
ok
(
!
ret
,
"Failed to create test key, %d.
\n
"
,
ret
);
RegCloseKey
(
hkey2
);
ret
=
RegDeleteKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Test"
);
ok
(
ret
==
ERROR_ACCESS_DENIED
,
"Unexpected return value %d.
\n
"
,
ret
);
ret
=
pSHDeleteKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Test"
);
ok
(
!
ret
,
"Failed to delete a key, %d.
\n
"
,
ret
);
ret
=
RegCloseKey
(
hkey
);
ok
(
!
ret
,
"Failed to delete a key, %d.
\n
"
,
ret
);
}
START_TEST
(
shcore
)
{
HMODULE
hshcore
=
LoadLibraryA
(
"shcore.dll"
);
...
...
@@ -337,4 +361,5 @@ START_TEST(shcore)
test_SHAnsiToAnsi
();
test_SHUnicodeToUnicode
();
test_SHRegDuplicateHKey
();
test_SHDeleteKey
();
}
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