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
b9bc9a0c
Commit
b9bc9a0c
authored
Apr 19, 2012
by
Huw Davies
Committed by
Alexandre Julliard
Apr 19, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winspool: Add a helper to open a printer's registry key.
parent
f6524a9f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
49 deletions
+30
-49
info.c
dlls/winspool.drv/info.c
+30
-49
No files found.
dlls/winspool.drv/info.c
View file @
b9bc9a0c
...
...
@@ -995,6 +995,21 @@ static LPCWSTR get_opened_printer_name(HANDLE hprn)
return
printer
->
name
;
}
static
DWORD
open_printer_reg_key
(
const
WCHAR
*
name
,
HKEY
*
key
)
{
HKEY
printers
;
DWORD
err
;
*
key
=
NULL
;
err
=
RegCreateKeyW
(
HKEY_LOCAL_MACHINE
,
PrintersW
,
&
printers
);
if
(
err
)
return
err
;
err
=
RegOpenKeyW
(
printers
,
name
,
key
);
if
(
err
)
err
=
ERROR_INVALID_PRINTER_NAME
;
RegCloseKey
(
printers
);
return
err
;
}
/******************************************************************
* WINSPOOL_GetOpenedPrinterRegKey
*
...
...
@@ -1002,24 +1017,9 @@ static LPCWSTR get_opened_printer_name(HANDLE hprn)
static
DWORD
WINSPOOL_GetOpenedPrinterRegKey
(
HANDLE
hPrinter
,
HKEY
*
phkey
)
{
LPCWSTR
name
=
get_opened_printer_name
(
hPrinter
);
DWORD
ret
;
HKEY
hkeyPrinters
;
if
(
!
name
)
return
ERROR_INVALID_HANDLE
;
if
((
ret
=
RegCreateKeyW
(
HKEY_LOCAL_MACHINE
,
PrintersW
,
&
hkeyPrinters
))
!=
ERROR_SUCCESS
)
return
ret
;
if
(
RegOpenKeyW
(
hkeyPrinters
,
name
,
phkey
)
!=
ERROR_SUCCESS
)
{
ERR
(
"Can't find opened printer %s in registry
\n
"
,
debugstr_w
(
name
));
RegCloseKey
(
hkeyPrinters
);
return
ERROR_INVALID_PRINTER_NAME
;
/* ? */
}
RegCloseKey
(
hkeyPrinters
);
return
ERROR_SUCCESS
;
return
open_printer_reg_key
(
name
,
phkey
);
}
void
WINSPOOL_LoadSystemPrinters
(
void
)
...
...
@@ -3872,30 +3872,18 @@ static BOOL WINSPOOL_GetPrinter_9(HKEY hkeyPrinter, PRINTER_INFO_9W *pi9, LPBYTE
BOOL
WINAPI
GetPrinterW
(
HANDLE
hPrinter
,
DWORD
Level
,
LPBYTE
pPrinter
,
DWORD
cbBuf
,
LPDWORD
pcbNeeded
)
{
LPCWSTR
name
;
DWORD
size
,
needed
=
0
;
DWORD
size
,
needed
=
0
,
err
;
LPBYTE
ptr
=
NULL
;
HKEY
hkeyPrinter
,
hkeyPrinters
;
HKEY
hkeyPrinter
;
BOOL
ret
;
TRACE
(
"(%p,%d,%p,%d,%p)
\n
"
,
hPrinter
,
Level
,
pPrinter
,
cbBuf
,
pcbNeeded
);
if
(
!
(
name
=
get_opened_printer_name
(
hPrinter
)))
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
if
(
RegCreateKeyW
(
HKEY_LOCAL_MACHINE
,
PrintersW
,
&
hkeyPrinters
)
!=
ERROR_SUCCESS
)
{
ERR
(
"Can't create Printers key
\n
"
);
return
FALSE
;
}
if
(
RegOpenKeyW
(
hkeyPrinters
,
name
,
&
hkeyPrinter
)
!=
ERROR_SUCCESS
)
err
=
WINSPOOL_GetOpenedPrinterRegKey
(
hPrinter
,
&
hkeyPrinter
);
if
(
err
)
{
ERR
(
"Can't find opened printer %s in registry
\n
"
,
debugstr_w
(
name
));
RegCloseKey
(
hkeyPrinters
);
SetLastError
(
ERROR_INVALID_PRINTER_NAME
);
/* ? */
return
FALSE
;
SetLastError
(
err
);
return
FALSE
;
}
switch
(
Level
)
{
...
...
@@ -4016,13 +4004,11 @@ BOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
default:
FIXME
(
"Unimplemented level %d
\n
"
,
Level
);
SetLastError
(
ERROR_INVALID_LEVEL
);
RegCloseKey
(
hkeyPrinters
);
RegCloseKey
(
hkeyPrinter
);
return
FALSE
;
}
RegCloseKey
(
hkeyPrinter
);
RegCloseKey
(
hkeyPrinters
);
TRACE
(
"returning %d needed = %d
\n
"
,
ret
,
needed
);
if
(
pcbNeeded
)
*
pcbNeeded
=
needed
;
...
...
@@ -4559,7 +4545,7 @@ BOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment,
WCHAR
DriverName
[
100
];
DWORD
ret
,
type
,
size
,
needed
=
0
;
LPBYTE
ptr
=
NULL
;
HKEY
hkeyPrinter
,
hkey
Printers
,
hkey
Drivers
;
HKEY
hkeyPrinter
,
hkeyDrivers
;
const
printenv_t
*
env
;
TRACE
(
"(%p,%s,%d,%p,%d,%p)
\n
"
,
hPrinter
,
debugstr_w
(
pEnvironment
),
...
...
@@ -4581,24 +4567,19 @@ BOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment,
env
=
validate_envW
(
pEnvironment
);
if
(
!
env
)
return
FALSE
;
/* SetLastError() is in validate_envW */
if
(
RegCreateKeyW
(
HKEY_LOCAL_MACHINE
,
PrintersW
,
&
hkeyPrinters
)
!=
ERROR_SUCCESS
)
{
ERR
(
"Can't create Printers key
\n
"
);
return
FALSE
;
}
if
(
RegOpenKeyW
(
hkeyPrinters
,
name
,
&
hkeyPrinter
)
!=
ERROR_SUCCESS
)
{
ERR
(
"Can't find opened printer %s in registry
\n
"
,
debugstr_w
(
name
));
RegCloseKey
(
hkeyPrinters
);
SetLastError
(
ERROR_INVALID_PRINTER_NAME
);
/* ? */
return
FALSE
;
ret
=
open_printer_reg_key
(
name
,
&
hkeyPrinter
);
if
(
ret
)
{
ERR
(
"Can't find opened printer %s in registry
\n
"
,
debugstr_w
(
name
)
);
SetLastError
(
ret
);
return
FALSE
;
}
size
=
sizeof
(
DriverName
);
DriverName
[
0
]
=
0
;
ret
=
RegQueryValueExW
(
hkeyPrinter
,
Printer_DriverW
,
0
,
&
type
,
(
LPBYTE
)
DriverName
,
&
size
);
RegCloseKey
(
hkeyPrinter
);
RegCloseKey
(
hkeyPrinters
);
if
(
ret
!=
ERROR_SUCCESS
)
{
ERR
(
"Can't get DriverName for printer %s
\n
"
,
debugstr_w
(
name
));
return
FALSE
;
...
...
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