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
77442049
Commit
77442049
authored
Sep 18, 2017
by
Hugh McMaster
Committed by
Alexandre Julliard
Sep 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit/tests: Use a helper function to write registry files.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
9ce39bd2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
regedit.c
programs/regedit/tests/regedit.c
+25
-27
No files found.
programs/regedit/tests/regedit.c
View file @
77442049
...
...
@@ -48,23 +48,33 @@ static BOOL run_regedit_exe_(unsigned line, const char *cmd)
return
(
ret
!=
WAIT_TIMEOUT
);
}
static
BOOL
write_file
(
const
void
*
str
,
DWORD
size
)
{
HANDLE
file
;
BOOL
ret
;
DWORD
written
;
file
=
CreateFileA
(
"test.reg"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
ok
(
file
!=
INVALID_HANDLE_VALUE
,
"Failed to create registry file
\n
"
);
if
(
file
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
ret
=
WriteFile
(
file
,
str
,
size
,
&
written
,
NULL
);
ok
(
ret
,
"WriteFile failed: %u
\n
"
,
GetLastError
());
CloseHandle
(
file
);
return
ret
;
}
#define exec_import_str(c) r_exec_import_str(__LINE__, c)
static
BOOL
r_exec_import_str
(
unsigned
line
,
const
char
*
file_contents
)
{
HANDLE
regfile
;
DWORD
written
;
BOOL
br
;
regfile
=
CreateFileA
(
"test.reg"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
lok
(
regfile
!=
INVALID_HANDLE_VALUE
,
"Failed to create test.reg file
\n
"
);
if
(
regfile
==
INVALID_HANDLE_VALUE
)
if
(
!
write_file
(
file_contents
,
strlen
(
file_contents
)))
return
FALSE
;
br
=
WriteFile
(
regfile
,
file_contents
,
strlen
(
file_contents
),
&
written
,
NULL
);
lok
(
br
,
"WriteFile failed: %u
\n
"
,
GetLastError
());
CloseHandle
(
regfile
);
run_regedit_exe
(
"regedit.exe /s test.reg"
);
br
=
DeleteFileA
(
"test.reg"
);
...
...
@@ -78,9 +88,7 @@ static BOOL r_exec_import_wstr(unsigned line, const char *file_contents)
{
int
lenA
,
len
,
memsize
;
WCHAR
*
wstr
;
HANDLE
regfile
;
DWORD
written
;
BOOL
br
;
BOOL
br
=
FALSE
;
lenA
=
strlen
(
file_contents
);
...
...
@@ -90,26 +98,16 @@ static BOOL r_exec_import_wstr(unsigned line, const char *file_contents)
if
(
!
wstr
)
return
FALSE
;
MultiByteToWideChar
(
CP_UTF8
,
0
,
file_contents
,
lenA
,
wstr
,
len
);
regfile
=
CreateFileA
(
"test.reg"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
lok
(
regfile
!=
INVALID_HANDLE_VALUE
,
"Failed to create test.reg file
\n
"
);
if
(
regfile
==
INVALID_HANDLE_VALUE
)
{
HeapFree
(
GetProcessHeap
(),
0
,
wstr
);
return
FALSE
;
}
br
=
WriteFile
(
regfile
,
wstr
,
memsize
,
&
written
,
NULL
);
lok
(
br
,
"WriteFile failed: %u
\n
"
,
GetLastError
());
CloseHandle
(
regfile
);
HeapFree
(
GetProcessHeap
(),
0
,
wstr
);
if
(
!
write_file
(
wstr
,
memsize
))
goto
exit
;
run_regedit_exe
(
"regedit.exe /s test.reg"
);
br
=
DeleteFileA
(
"test.reg"
);
lok
(
br
,
"DeleteFile failed: %u
\n
"
,
GetLastError
());
exit:
HeapFree
(
GetProcessHeap
(),
0
,
wstr
);
return
br
;
}
...
...
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