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
178294a4
Commit
178294a4
authored
Oct 13, 2010
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Oct 13, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winspool: Implement SetDefaultPrinterA/W.
parent
9c027606
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
6 deletions
+92
-6
info.c
dlls/winspool.drv/info.c
+92
-6
No files found.
dlls/winspool.drv/info.c
View file @
178294a4
...
...
@@ -5258,11 +5258,91 @@ end:
*/
BOOL
WINAPI
SetDefaultPrinterW
(
LPCWSTR
pszPrinter
)
{
WCHAR
default_printer
[
MAX_PATH
];
LPWSTR
buffer
=
NULL
;
HKEY
hreg
;
DWORD
size
;
DWORD
namelen
;
LONG
lres
;
TRACE
(
"(%s)
\n
"
,
debugstr_w
(
pszPrinter
));
if
((
pszPrinter
==
NULL
)
||
(
pszPrinter
[
0
]
==
'\0'
))
{
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
return
FALSE
;
default_printer
[
0
]
=
'\0'
;
size
=
sizeof
(
default_printer
)
/
sizeof
(
WCHAR
);
/* if we have a default Printer, do nothing. */
if
(
GetDefaultPrinterW
(
default_printer
,
&
size
))
return
TRUE
;
pszPrinter
=
NULL
;
/* we have no default Printer: search local Printers and use the first */
if
(
!
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
PrintersW
,
0
,
KEY_READ
,
&
hreg
))
{
default_printer
[
0
]
=
'\0'
;
size
=
sizeof
(
default_printer
)
/
sizeof
(
WCHAR
);
if
(
!
RegEnumKeyExW
(
hreg
,
0
,
default_printer
,
&
size
,
NULL
,
NULL
,
NULL
,
NULL
))
{
pszPrinter
=
default_printer
;
TRACE
(
"using %s
\n
"
,
debugstr_w
(
pszPrinter
));
}
RegCloseKey
(
hreg
);
}
if
(
pszPrinter
==
NULL
)
{
TRACE
(
"no local printer found
\n
"
);
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
FALSE
;
}
}
/* "pszPrinter" is never empty or NULL here. */
namelen
=
lstrlenW
(
pszPrinter
);
size
=
namelen
+
(
MAX_PATH
*
2
)
+
3
;
/* printer,driver,port and a 0 */
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
));
if
(
!
buffer
||
(
RegOpenKeyExW
(
HKEY_CURRENT_USER
,
user_printers_reg_key
,
0
,
KEY_READ
,
&
hreg
)
!=
ERROR_SUCCESS
))
{
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
FALSE
;
}
/* read the devices entry for the printer (driver,port) to build the string for the
default device entry (printer,driver,port) */
memcpy
(
buffer
,
pszPrinter
,
namelen
*
sizeof
(
WCHAR
));
buffer
[
namelen
]
=
','
;
namelen
++
;
/* move index to the start of the driver */
size
=
((
MAX_PATH
*
2
)
+
2
)
*
sizeof
(
WCHAR
);
/* driver,port and a 0 */
lres
=
RegQueryValueExW
(
hreg
,
pszPrinter
,
NULL
,
NULL
,
(
LPBYTE
)
(
&
buffer
[
namelen
]),
&
size
);
if
(
!
lres
)
{
TRACE
(
"set device to %s
\n
"
,
debugstr_w
(
buffer
));
if
(
!
WriteProfileStringW
(
windowsW
,
deviceW
,
buffer
))
{
TRACE
(
"failed to set the device entry: %d
\n
"
,
GetLastError
());
lres
=
ERROR_INVALID_PRINTER_NAME
;
}
/* remove the next section, when INIFileMapping is implemented */
{
HKEY
hdev
;
if
(
!
RegCreateKeyW
(
HKEY_CURRENT_USER
,
user_default_reg_key
,
&
hdev
))
{
RegSetValueExW
(
hdev
,
deviceW
,
0
,
REG_SZ
,
(
LPBYTE
)
buffer
,
(
lstrlenW
(
buffer
)
+
1
)
*
sizeof
(
WCHAR
));
RegCloseKey
(
hdev
);
}
}
}
else
{
if
(
lres
!=
ERROR_FILE_NOT_FOUND
)
FIXME
(
"RegQueryValueExW failed with %d for %s
\n
"
,
lres
,
debugstr_w
(
pszPrinter
));
SetLastError
(
ERROR_INVALID_PRINTER_NAME
);
}
RegCloseKey
(
hreg
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
(
lres
==
ERROR_SUCCESS
);
}
/******************************************************************************
...
...
@@ -5273,14 +5353,20 @@ BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
*/
BOOL
WINAPI
SetDefaultPrinterA
(
LPCSTR
pszPrinter
)
{
LPWSTR
bufferW
=
NULL
;
BOOL
res
;
TRACE
(
"(%s)
\n
"
,
debugstr_a
(
pszPrinter
));
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
return
FALSE
;
if
(
pszPrinter
)
{
INT
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
pszPrinter
,
-
1
,
NULL
,
0
);
bufferW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
if
(
bufferW
)
MultiByteToWideChar
(
CP_ACP
,
0
,
pszPrinter
,
-
1
,
bufferW
,
len
);
}
res
=
SetDefaultPrinterW
(
bufferW
);
HeapFree
(
GetProcessHeap
(),
0
,
bufferW
);
return
res
;
}
/******************************************************************************
* SetPrinterDataExA (WINSPOOL.@)
*/
...
...
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