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
ce9f0463
Commit
ce9f0463
authored
Mar 18, 2012
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Mar 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comdlg32: Use a helper to get the printer driver info.
parent
d0f5397b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
29 deletions
+54
-29
printdlg.c
dlls/comdlg32/printdlg.c
+54
-29
No files found.
dlls/comdlg32/printdlg.c
View file @
ce9f0463
...
...
@@ -162,6 +162,53 @@ static LPWSTR strdupW(LPCWSTR p)
}
/***********************************************************************
* get_driver_info [internal]
*
* get DRIVER_INFO_3W for the current printer handle,
* alloc the buffer, when needed
*/
static
DRIVER_INFO_3W
*
get_driver_infoW
(
HANDLE
hprn
)
{
DRIVER_INFO_3W
*
di3
=
NULL
;
DWORD
needed
=
0
;
BOOL
res
;
res
=
GetPrinterDriverW
(
hprn
,
NULL
,
3
,
NULL
,
0
,
&
needed
);
if
(
!
res
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
))
{
di3
=
HeapAlloc
(
GetProcessHeap
(),
0
,
needed
);
res
=
GetPrinterDriverW
(
hprn
,
NULL
,
3
,
(
LPBYTE
)
di3
,
needed
,
&
needed
);
}
if
(
res
)
return
di3
;
TRACE
(
"GetPrinterDriverW failed with %u
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
di3
);
return
NULL
;
}
static
DRIVER_INFO_3A
*
get_driver_infoA
(
HANDLE
hprn
)
{
DRIVER_INFO_3A
*
di3
=
NULL
;
DWORD
needed
=
0
;
BOOL
res
;
res
=
GetPrinterDriverA
(
hprn
,
NULL
,
3
,
NULL
,
0
,
&
needed
);
if
(
!
res
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
))
{
di3
=
HeapAlloc
(
GetProcessHeap
(),
0
,
needed
);
res
=
GetPrinterDriverA
(
hprn
,
NULL
,
3
,
(
LPBYTE
)
di3
,
needed
,
&
needed
);
}
if
(
res
)
return
di3
;
TRACE
(
"GetPrinterDriverA failed with %u
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
di3
);
return
NULL
;
}
/***********************************************************************
* get_printer_info [internal]
*
* get PRINTER_INFO_2W for the current printer handle,
...
...
@@ -3848,10 +3895,8 @@ HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
if
(
lppd
->
Flags
&
PD_RETURNDEFAULT
)
{
PRINTER_INFO_2A
*
pbuf
;
DRIVER_INFO_
2
A
*
dbuf
;
DRIVER_INFO_
3
A
*
dbuf
;
HANDLE
hprn
;
DWORD
needed
=
1024
;
BOOL
bRet
;
if
(
lppd
->
hDevMode
||
lppd
->
hDevNames
)
{
...
...
@@ -3873,19 +3918,9 @@ HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
return
E_FAIL
;
}
dbuf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
needed
);
bRet
=
GetPrinterDriverA
(
hprn
,
NULL
,
3
,
(
LPBYTE
)
dbuf
,
needed
,
&
needed
);
if
(
!
bRet
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
))
dbuf
=
get_driver_infoA
(
hprn
);
if
(
!
dbuf
)
{
HeapFree
(
GetProcessHeap
(),
0
,
dbuf
);
dbuf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
needed
);
bRet
=
GetPrinterDriverA
(
hprn
,
NULL
,
3
,
(
LPBYTE
)
dbuf
,
needed
,
&
needed
);
}
if
(
!
bRet
)
{
ERR
(
"GetPrinterDriverА failed, last error %d, fix your config for printer %s!
\n
"
,
GetLastError
(),
pbuf
->
pPrinterName
);
HeapFree
(
GetProcessHeap
(),
0
,
dbuf
);
HeapFree
(
GetProcessHeap
(),
0
,
pbuf
);
COMDLG32_SetCommDlgExtendedError
(
PDERR_RETDEFFAILURE
);
ClosePrinter
(
hprn
);
...
...
@@ -3976,10 +4011,8 @@ HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
if
(
lppd
->
Flags
&
PD_RETURNDEFAULT
)
{
PRINTER_INFO_2W
*
pbuf
;
DRIVER_INFO_
2
W
*
dbuf
;
DRIVER_INFO_
3
W
*
dbuf
;
HANDLE
hprn
;
DWORD
needed
=
1024
;
BOOL
bRet
;
if
(
lppd
->
hDevMode
||
lppd
->
hDevNames
)
{
WARN
(
"hDevMode or hDevNames non-zero for PD_RETURNDEFAULT
\n
"
);
...
...
@@ -3999,17 +4032,9 @@ HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
return
E_FAIL
;
}
dbuf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
needed
);
bRet
=
GetPrinterDriverW
(
hprn
,
NULL
,
3
,
(
LPBYTE
)
dbuf
,
needed
,
&
needed
);
if
(
!
bRet
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
))
{
HeapFree
(
GetProcessHeap
(),
0
,
dbuf
);
dbuf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
needed
);
bRet
=
GetPrinterDriverW
(
hprn
,
NULL
,
3
,
(
LPBYTE
)
dbuf
,
needed
,
&
needed
);
}
if
(
!
bRet
)
{
ERR
(
"GetPrinterDriverW failed, last error %d, fix your config for printer %s!
\n
"
,
GetLastError
(),
debugstr_w
(
pbuf
->
pPrinterName
));
HeapFree
(
GetProcessHeap
(),
0
,
dbuf
);
dbuf
=
get_driver_infoW
(
hprn
);
if
(
!
dbuf
)
{
HeapFree
(
GetProcessHeap
(),
0
,
pbuf
);
COMDLG32_SetCommDlgExtendedError
(
PDERR_RETDEFFAILURE
);
ClosePrinter
(
hprn
);
...
...
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