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
d5e2b7c8
Commit
d5e2b7c8
authored
Feb 21, 2005
by
James Hawkins
Committed by
Alexandre Julliard
Feb 21, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RegOpenKey, RegCloseKey tests.
parent
5cb9507e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
1 deletion
+104
-1
registry.c
dlls/advapi32/registry.c
+12
-1
registry.c
dlls/advapi32/tests/registry.c
+92
-0
No files found.
dlls/advapi32/registry.c
View file @
d5e2b7c8
...
@@ -277,6 +277,11 @@ DWORD WINAPI RegOpenKeyExW( HKEY hkey, LPCWSTR name, DWORD reserved, REGSAM acce
...
@@ -277,6 +277,11 @@ DWORD WINAPI RegOpenKeyExW( HKEY hkey, LPCWSTR name, DWORD reserved, REGSAM acce
OBJECT_ATTRIBUTES
attr
;
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
UNICODE_STRING
nameW
;
if
(
!
name
||
!*
name
)
{
*
retkey
=
hkey
;
return
ERROR_SUCCESS
;
}
if
(
!
(
hkey
=
get_special_root_hkey
(
hkey
)))
return
ERROR_INVALID_HANDLE
;
if
(
!
(
hkey
=
get_special_root_hkey
(
hkey
)))
return
ERROR_INVALID_HANDLE
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
Length
=
sizeof
(
attr
);
...
@@ -316,6 +321,11 @@ DWORD WINAPI RegOpenKeyExA( HKEY hkey, LPCSTR name, DWORD reserved, REGSAM acces
...
@@ -316,6 +321,11 @@ DWORD WINAPI RegOpenKeyExA( HKEY hkey, LPCSTR name, DWORD reserved, REGSAM acces
STRING
nameA
;
STRING
nameA
;
NTSTATUS
status
;
NTSTATUS
status
;
if
(
!
name
||
!*
name
)
{
*
retkey
=
hkey
;
return
ERROR_SUCCESS
;
}
if
(
!
is_version_nt
())
access
=
KEY_ALL_ACCESS
;
/* Win95 ignores the access mask */
if
(
!
is_version_nt
())
access
=
KEY_ALL_ACCESS
;
/* Win95 ignores the access mask */
if
(
!
(
hkey
=
get_special_root_hkey
(
hkey
)))
return
ERROR_INVALID_HANDLE
;
if
(
!
(
hkey
=
get_special_root_hkey
(
hkey
)))
return
ERROR_INVALID_HANDLE
;
...
@@ -845,7 +855,8 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
...
@@ -845,7 +855,8 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
*/
*/
DWORD
WINAPI
RegCloseKey
(
HKEY
hkey
)
DWORD
WINAPI
RegCloseKey
(
HKEY
hkey
)
{
{
if
(
!
hkey
||
hkey
>=
(
HKEY
)
0x80000000
)
return
ERROR_SUCCESS
;
if
(
!
hkey
)
return
ERROR_INVALID_PARAMETER
;
if
(
hkey
>=
(
HKEY
)
0x80000000
)
return
ERROR_SUCCESS
;
return
RtlNtStatusToDosError
(
NtClose
(
hkey
)
);
return
RtlNtStatusToDosError
(
NtClose
(
hkey
)
);
}
}
...
...
dlls/advapi32/tests/registry.c
View file @
d5e2b7c8
...
@@ -254,12 +254,104 @@ static void test_query_value_ex()
...
@@ -254,12 +254,104 @@ static void test_query_value_ex()
ok
(
type
==
REG_SZ
,
"type %ld is not REG_SZ
\n
"
,
type
);
ok
(
type
==
REG_SZ
,
"type %ld is not REG_SZ
\n
"
,
type
);
}
}
static
void
test_reg_open_key
()
{
DWORD
ret
=
0
;
HKEY
hkResult
=
NULL
;
HKEY
hkPreserve
=
NULL
;
/* successful open */
ret
=
RegOpenKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Test"
,
&
hkResult
);
ok
(
ret
==
ERROR_SUCCESS
,
"expected ERROR_SUCCESS, got %ld
\n
"
,
ret
);
ok
(
hkResult
!=
NULL
,
"expected hkResult != NULL
\n
"
);
hkPreserve
=
hkResult
;
/* open same key twice */
ret
=
RegOpenKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Test"
,
&
hkResult
);
ok
(
ret
==
ERROR_SUCCESS
,
"expected ERROR_SUCCESS, got %ld
\n
"
,
ret
);
ok
(
hkResult
!=
hkPreserve
&&
hkResult
!=
NULL
,
"expected hkResult != hkPreserve and hkResult != NULL
\n
"
);
RegCloseKey
(
hkResult
);
/* open nonexistent key
* check that hkResult is set to NULL
*/
hkResult
=
hkPreserve
;
ret
=
RegOpenKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Nonexistent"
,
&
hkResult
);
ok
(
ret
==
ERROR_FILE_NOT_FOUND
,
"expected ERROR_FILE_NOT_FOUND, got %ld
\n
"
,
ret
);
ok
(
hkResult
==
NULL
,
"expected hkResult == NULL
\n
"
);
/* open the same nonexistent key again to make sure the key wasn't created */
hkResult
=
hkPreserve
;
ret
=
RegOpenKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Nonexistent"
,
&
hkResult
);
ok
(
ret
==
ERROR_FILE_NOT_FOUND
,
"expected ERROR_FILE_NOT_FOUND, got %ld
\n
"
,
ret
);
ok
(
hkResult
==
NULL
,
"expected hkResult == NULL
\n
"
);
/* send in NULL lpSubKey
* check that hkResult receives the value of hKey
*/
hkResult
=
hkPreserve
;
ret
=
RegOpenKeyA
(
HKEY_CURRENT_USER
,
NULL
,
&
hkResult
);
ok
(
ret
==
ERROR_SUCCESS
,
"expected ERROR_SUCCESS, got %ld
\n
"
,
ret
);
ok
(
hkResult
==
HKEY_CURRENT_USER
,
"expected hkResult == HKEY_CURRENT_USER
\n
"
);
/* send empty-string in lpSubKey */
hkResult
=
hkPreserve
;
ret
=
RegOpenKeyA
(
HKEY_CURRENT_USER
,
""
,
&
hkResult
);
ok
(
ret
==
ERROR_SUCCESS
,
"expected ERROR_SUCCESS, got %ld
\n
"
,
ret
);
ok
(
hkResult
==
HKEY_CURRENT_USER
,
"expected hkResult == HKEY_CURRENT_USER
\n
"
);
/* send in NULL lpSubKey and NULL hKey
* hkResult is set to NULL
*/
hkResult
=
hkPreserve
;
ret
=
RegOpenKeyA
(
NULL
,
NULL
,
&
hkResult
);
ok
(
ret
==
ERROR_SUCCESS
,
"expected ERROR_SUCCESS, got %ld
\n
"
,
ret
);
ok
(
hkResult
==
NULL
,
"expected hkResult == NULL
\n
"
);
/* only send NULL hKey
* the value of hkResult remains unchanged
*/
hkResult
=
hkPreserve
;
ret
=
RegOpenKeyA
(
NULL
,
"Software
\\
Wine
\\
Test"
,
&
hkResult
);
ok
(
ret
==
ERROR_INVALID_HANDLE
,
"expected ERROR_INVALID_HANDLE, got %ld
\n
"
,
ret
);
ok
(
hkResult
==
hkPreserve
,
"expected hkResult == hkPreserve
\n
"
);
RegCloseKey
(
hkResult
);
/* send in NULL hkResult */
ret
=
RegOpenKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Test"
,
NULL
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %ld
\n
"
,
ret
);
}
static
void
test_reg_close_key
()
{
DWORD
ret
=
0
;
HKEY
hkHandle
;
/* successfully close key
* hkHandle remains changed after call to RegCloseKey
*/
ret
=
RegOpenKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
Test"
,
&
hkHandle
);
ret
=
RegCloseKey
(
hkHandle
);
ok
(
ret
==
ERROR_SUCCESS
,
"expected ERROR_SUCCESS, got %ld
\n
"
,
ret
);
/* try to close the key twice */
ret
=
RegCloseKey
(
hkHandle
);
ok
(
ret
==
ERROR_INVALID_HANDLE
,
"expected ERROR_INVALID_HANDLE, got %ld
\n
"
,
ret
);
/* try to close a NULL handle */
ret
=
RegCloseKey
(
NULL
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %ld
\n
"
,
ret
);
}
START_TEST
(
registry
)
START_TEST
(
registry
)
{
{
setup_main_key
();
setup_main_key
();
create_test_entries
();
create_test_entries
();
test_enum_value
();
test_enum_value
();
test_query_value_ex
();
test_query_value_ex
();
test_reg_open_key
();
test_reg_close_key
();
/* cleanup */
/* cleanup */
delete_key
(
hkey_main
);
delete_key
(
hkey_main
);
...
...
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