ReactOS 0.4.15-dev-7842-g558ab78
printerdrivers.c File Reference
Include dependency graph for printerdrivers.c:

Go to the source code of this file.

Functions

static int multi_sz_lenA (const char *str)
 
static int multi_sz_lenW (const WCHAR *str)
 
BOOL WINAPI AddPrinterDriverA (PSTR pName, DWORD Level, PBYTE pDriverInfo)
 
BOOL WINAPI AddPrinterDriverExA (PSTR pName, DWORD Level, PBYTE pDriverInfo, DWORD dwFileCopyFlags)
 
BOOL WINAPI AddPrinterDriverExW (PWSTR pName, DWORD Level, PBYTE pDriverInfo, DWORD dwFileCopyFlags)
 
BOOL WINAPI AddPrinterDriverW (PWSTR pName, DWORD Level, PBYTE pDriverInfo)
 
BOOL WINAPI DeletePrinterDriverA (PSTR pName, PSTR pEnvironment, PSTR pDriverName)
 
BOOL WINAPI DeletePrinterDriverExA (PSTR pName, PSTR pEnvironment, PSTR pDriverName, DWORD dwDeleteFlag, DWORD dwVersionFlag)
 
BOOL WINAPI DeletePrinterDriverExW (PWSTR pName, PWSTR pEnvironment, PWSTR pDriverName, DWORD dwDeleteFlag, DWORD dwVersionFlag)
 
BOOL WINAPI DeletePrinterDriverW (PWSTR pName, PWSTR pEnvironment, PWSTR pDriverName)
 
BOOL WINAPI EnumPrinterDriversA (PSTR pName, PSTR pEnvironment, DWORD Level, PBYTE pDriverInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI EnumPrinterDriversW (PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pDriverInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI GetPrinterDriverA (HANDLE hPrinter, LPSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
 
BOOL WINAPI GetPrinterDriverW (HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
 
BOOL WINAPI GetPrinterDriverDirectoryA (PSTR pName, PSTR pEnvironment, DWORD Level, PBYTE pDriverDirectory, DWORD cbBuf, PDWORD pcbNeeded)
 
BOOL WINAPI GetPrinterDriverDirectoryW (PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pDriverDirectory, DWORD cbBuf, PDWORD pcbNeeded)
 

Variables

const WCHAR wszCurrentEnvironment []
 

Function Documentation

◆ AddPrinterDriverA()

BOOL WINAPI AddPrinterDriverA ( PSTR  pName,
DWORD  Level,
PBYTE  pDriverInfo 
)

Definition at line 38 of file printerdrivers.c.

39{
40 TRACE("AddPrinterDriverA(%s, %lu, %p)\n", pName, Level, pDriverInfo);
42}
BOOL WINAPI AddPrinterDriverExA(PSTR pName, DWORD Level, PBYTE pDriverInfo, DWORD dwFileCopyFlags)
static LPSTR pName
Definition: security.c:75
#define TRACE(s)
Definition: solgame.cpp:4
#define APD_COPY_NEW_FILES
Definition: winspool.h:606
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56

◆ AddPrinterDriverExA()

BOOL WINAPI AddPrinterDriverExA ( PSTR  pName,
DWORD  Level,
PBYTE  pDriverInfo,
DWORD  dwFileCopyFlags 
)

Definition at line 45 of file printerdrivers.c.

46{
47 PDRIVER_INFO_8A pdiA;
50 DWORD lenA;
51 DWORD len;
52 BOOL res = FALSE;
53
54 TRACE("AddPrinterDriverExA(%s, %d, %p, 0x%x)\n", debugstr_a(pName), Level, pDriverInfo, dwFileCopyFlags);
55
56 pdiA = (DRIVER_INFO_8A *) pDriverInfo;
57 ZeroMemory(&diW, sizeof(diW));
58
59 if (Level < 2 || Level == 5 || Level == 7 || Level > 8)
60 {
62 return FALSE;
63 }
64
65 if (pdiA == NULL)
66 {
68 return FALSE;
69 }
70
71 /* convert servername to unicode */
72 if (pName)
73 {
75 nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
77 }
78
79 /* common fields */
80 diW.cVersion = pdiA->cVersion;
81
82 if (pdiA->pName)
83 {
84 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pName, -1, NULL, 0);
85 diW.pName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
86 MultiByteToWideChar(CP_ACP, 0, pdiA->pName, -1, diW.pName, len);
87 }
88
89 if (pdiA->pEnvironment)
90 {
91 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pEnvironment, -1, NULL, 0);
92 diW.pEnvironment = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
94 }
95
96 if (pdiA->pDriverPath)
97 {
98 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pDriverPath, -1, NULL, 0);
99 diW.pDriverPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
101 }
102
103 if (pdiA->pDataFile)
104 {
105 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pDataFile, -1, NULL, 0);
106 diW.pDataFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
107 MultiByteToWideChar(CP_ACP, 0, pdiA->pDataFile, -1, diW.pDataFile, len);
108 }
109
110 if (pdiA->pConfigFile)
111 {
112 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pConfigFile, -1, NULL, 0);
113 diW.pConfigFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
115 }
116
117 if ((Level > 2) && pdiA->pHelpFile)
118 {
119 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pHelpFile, -1, NULL, 0);
120 diW.pHelpFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
121 MultiByteToWideChar(CP_ACP, 0, pdiA->pHelpFile, -1, diW.pHelpFile, len);
122 }
123
124 if ((Level > 2) && pdiA->pDependentFiles)
125 {
126 lenA = multi_sz_lenA(pdiA->pDependentFiles);
127 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pDependentFiles, lenA, NULL, 0);
128 diW.pDependentFiles = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
130 }
131
132 if ((Level > 2) && pdiA->pMonitorName)
133 {
134 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pMonitorName, -1, NULL, 0);
135 diW.pMonitorName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
137 }
138
139 if ((Level > 2) && pdiA->pDefaultDataType)
140 {
142 diW.pDefaultDataType = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
144 }
145
146 if ((Level > 3) && pdiA->pszzPreviousNames)
147 {
148 lenA = multi_sz_lenA(pdiA->pszzPreviousNames);
149 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pszzPreviousNames, lenA, NULL, 0);
150 diW.pszzPreviousNames = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
152 }
153
154 if (Level > 5)
155 {
156 diW.ftDriverDate = pdiA->ftDriverDate;
158 }
159
160 if ((Level > 5) && pdiA->pszMfgName)
161 {
162 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pszMfgName, -1, NULL, 0);
163 diW.pszMfgName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
165 }
166
167 if ((Level > 5) && pdiA->pszOEMUrl)
168 {
169 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pszOEMUrl, -1, NULL, 0);
170 diW.pszOEMUrl = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
171 MultiByteToWideChar(CP_ACP, 0, pdiA->pszOEMUrl, -1, diW.pszOEMUrl, len);
172 }
173
174 if ((Level > 5) && pdiA->pszHardwareID)
175 {
176 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pszHardwareID, -1, NULL, 0);
177 diW.pszHardwareID = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
179 }
180
181 if ((Level > 5) && pdiA->pszProvider)
182 {
183 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pszProvider, -1, NULL, 0);
184 diW.pszProvider = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
186 }
187
188 if ((Level > 7) && pdiA->pszPrintProcessor)
189 {
191 diW.pszPrintProcessor = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
193 }
194
195 if ((Level > 7) && pdiA->pszVendorSetup)
196 {
197 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pszVendorSetup, -1, NULL, 0);
198 diW.pszVendorSetup = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
200 }
201
202 if ((Level > 7) && pdiA->pszzColorProfiles)
203 {
204 lenA = multi_sz_lenA(pdiA->pszzColorProfiles);
205 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pszzColorProfiles, lenA, NULL, 0);
206 diW.pszzColorProfiles = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
208 }
209
210 if ((Level > 7) && pdiA->pszInfPath)
211 {
212 len = MultiByteToWideChar(CP_ACP, 0, pdiA->pszInfPath, -1, NULL, 0);
213 diW.pszInfPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
215 }
216
217 if ((Level > 7) && pdiA->pszzCoreDriverDependencies)
218 {
223 }
224
225 if (Level > 7)
226 {
230 }
231
232 res = AddPrinterDriverExW(nameW, Level, (LPBYTE) &diW, dwFileCopyFlags);
233
234 TRACE("got %u with %u\n", res, GetLastError());
236 if (diW.pName) HeapFree(GetProcessHeap(), 0, diW.pName);
239 if (diW.pDataFile) HeapFree(GetProcessHeap(), 0, diW.pDataFile);
241 if (diW.pHelpFile) HeapFree(GetProcessHeap(), 0, diW.pHelpFile);
246 if (diW.pszMfgName) HeapFree(GetProcessHeap(), 0, diW.pszMfgName);
247 if (diW.pszOEMUrl) HeapFree(GetProcessHeap(), 0, diW.pszOEMUrl);
253 if (diW.pszInfPath) HeapFree(GetProcessHeap(), 0, diW.pszInfPath);
255
256 TRACE("=> %u with %u\n", res, GetLastError());
257 return res;
258}
static const WCHAR nameW[]
Definition: main.c:46
BOOL WINAPI AddPrinterDriverExW(PWSTR pName, DWORD Level, PBYTE pDriverInfo, DWORD dwFileCopyFlags)
static int multi_sz_lenA(const char *str)
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_a
Definition: kernel32.h:31
LPSTR pszzPreviousNames
Definition: winspool.h:575
FILETIME ftMinInboxDriverVerDate
Definition: winspool.h:588
DWORD dwPrinterDriverAttributes
Definition: winspool.h:586
DWORDLONG dwlDriverVersion
Definition: winspool.h:577
LPSTR pDefaultDataType
Definition: winspool.h:574
LPSTR pszPrintProcessor
Definition: winspool.h:582
LPSTR pszzColorProfiles
Definition: winspool.h:584
LPSTR pszzCoreDriverDependencies
Definition: winspool.h:587
LPSTR pMonitorName
Definition: winspool.h:573
LPSTR pszHardwareID
Definition: winspool.h:580
LPSTR pDataFile
Definition: winspool.h:569
LPSTR pszProvider
Definition: winspool.h:581
LPSTR pDriverPath
Definition: winspool.h:568
LPSTR pszMfgName
Definition: winspool.h:578
DWORDLONG dwlMinInboxDriverVerVersion
Definition: winspool.h:589
LPSTR pDependentFiles
Definition: winspool.h:572
LPSTR pszVendorSetup
Definition: winspool.h:583
LPSTR pszInfPath
Definition: winspool.h:585
FILETIME ftDriverDate
Definition: winspool.h:576
LPSTR pszOEMUrl
Definition: winspool.h:579
DWORD cVersion
Definition: winspool.h:565
LPSTR pEnvironment
Definition: winspool.h:567
LPSTR pConfigFile
Definition: winspool.h:570
LPSTR pHelpFile
Definition: winspool.h:571
DWORD cVersion
Definition: winspool.h:537
LPWSTR pszVendorSetup
Definition: winspool.h:555
LPWSTR pDependentFiles
Definition: winspool.h:544
LPWSTR pDataFile
Definition: winspool.h:541
LPWSTR pszPrintProcessor
Definition: winspool.h:554
LPWSTR pEnvironment
Definition: winspool.h:539
LPWSTR pszMfgName
Definition: winspool.h:550
DWORDLONG dwlMinInboxDriverVerVersion
Definition: winspool.h:561
LPWSTR pszzCoreDriverDependencies
Definition: winspool.h:559
LPWSTR pDriverPath
Definition: winspool.h:540
DWORDLONG dwlDriverVersion
Definition: winspool.h:549
FILETIME ftMinInboxDriverVerDate
Definition: winspool.h:560
LPWSTR pszzColorProfiles
Definition: winspool.h:556
LPWSTR pDefaultDataType
Definition: winspool.h:546
DWORD dwPrinterDriverAttributes
Definition: winspool.h:558
LPWSTR pMonitorName
Definition: winspool.h:545
LPWSTR pszInfPath
Definition: winspool.h:557
LPWSTR pszProvider
Definition: winspool.h:553
LPWSTR pszOEMUrl
Definition: winspool.h:551
LPWSTR pConfigFile
Definition: winspool.h:542
LPWSTR pszzPreviousNames
Definition: winspool.h:547
LPWSTR pszHardwareID
Definition: winspool.h:552
LPWSTR pHelpFile
Definition: winspool.h:543
FILETIME ftDriverDate
Definition: winspool.h:548
LPWSTR pName
Definition: winspool.h:538
unsigned char * LPBYTE
Definition: typedefs.h:53
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AddPrinterDriverA().

◆ AddPrinterDriverExW()

BOOL WINAPI AddPrinterDriverExW ( PWSTR  pName,
DWORD  Level,
PBYTE  pDriverInfo,
DWORD  dwFileCopyFlags 
)

Definition at line 261 of file printerdrivers.c.

262{
263 DWORD dwErrorCode = ERROR_SUCCESS;
265 WINSPOOL_DRIVER_CONTAINER pDriverContainer;
266
267 TRACE("AddPrinterDriverExW(%S, %lu, %p, %lu)\n", pName, Level, pDriverInfo, dwFileCopyFlags);
268
269 pDriverContainer.Level = Level;
270
271 switch (Level)
272 {
273 case 8:
274 {
275 PDRIVER_INFO_8W pdi8w = (PDRIVER_INFO_8W)pDriverInfo;
277
278 pdi->pPrintProcessor = pdi8w->pszPrintProcessor;
279 pdi->pVendorSetup = pdi8w->pszVendorSetup;
280
281 pdi->pszzColorProfiles = pdi8w->pszzColorProfiles;
282 pdi->cchColorProfiles = 0;
283 if ( pdi8w->pszzColorProfiles && *pdi8w->pszzColorProfiles )
284 {
285 pdi->cchColorProfiles = multi_sz_lenW( pdi8w->pszzColorProfiles );
286 }
287
288 pdi->pInfPath = pdi8w->pszInfPath;
289
290 pdi->pszzCoreDriverDependencies = pdi8w->pszzCoreDriverDependencies;
291 pdi->cchCoreDependencies = 0;
293 {
294 pdi->cchCoreDependencies = multi_sz_lenW( pdi8w->pszzCoreDriverDependencies );
295 }
296
297 pdi->ftMinInboxDriverVerDate = pdi8w->ftMinInboxDriverVerDate;
298 pdi->dwlMinInboxDriverVerVersion = pdi8w->dwlMinInboxDriverVerVersion;
299 }
300 case 6:
301 {
302 PDRIVER_INFO_6W pdi6w = (PDRIVER_INFO_6W)pDriverInfo;
303 if ( pdi == NULL ) pdi = HeapAlloc(hProcessHeap, 0, sizeof(WINSPOOL_DRIVER_INFO_6));
304
305 pdi->pMfgName = pdi6w->pszMfgName;
306 pdi->pOEMUrl = pdi6w->pszOEMUrl;
307 pdi->pHardwareID = pdi6w->pszHardwareID;
308 pdi->pProvider = pdi6w->pszProvider;
309 pdi->ftDriverDate = pdi6w->ftDriverDate;
310 pdi->dwlDriverVersion = pdi6w->dwlDriverVersion;
311 }
312 case 4:
313 {
314 PDRIVER_INFO_4W pdi4w = (PDRIVER_INFO_4W)pDriverInfo;
315 if ( pdi == NULL ) pdi = HeapAlloc(hProcessHeap, 0, sizeof(WINSPOOL_DRIVER_INFO_4));
316
317 pdi->pszzPreviousNames = pdi4w->pszzPreviousNames;
318 pdi->cchPreviousNames = 0;
319 if ( pdi4w->pDependentFiles && *pdi4w->pDependentFiles )
320 {
321 pdi->cchPreviousNames = multi_sz_lenW( pdi4w->pDependentFiles );
322 }
323 }
324 case 3:
325 {
326 PDRIVER_INFO_3W pdi3w = (PDRIVER_INFO_3W)pDriverInfo;
327 if ( pdi == NULL ) pdi = HeapAlloc(hProcessHeap, 0, sizeof(WINSPOOL_DRIVER_INFO_3));
328
329 pdi->pHelpFile = pdi3w->pHelpFile;
330 pdi->pDependentFiles = pdi3w->pDependentFiles;
331 pdi->pMonitorName = pdi3w->pMonitorName;
332 pdi->pDefaultDataType = pdi3w->pDefaultDataType;
333
334 pdi->pDependentFiles = pdi3w->pDependentFiles;
335 pdi->cchDependentFiles = 0;
336 if ( pdi3w->pDependentFiles && *pdi3w->pDependentFiles )
337 {
338 pdi->cchDependentFiles = multi_sz_lenW( pdi3w->pDependentFiles );
339 }
340 }
341 case 2:
342 {
343 PDRIVER_INFO_2W pdi2w = (PDRIVER_INFO_2W)pDriverInfo;
344 if ( pdi == NULL ) pdi = HeapAlloc(hProcessHeap, 0, sizeof(WINSPOOL_DRIVER_INFO_2));
345
346 pdi->pName = pdi2w->pName;
347
348 pdi->pEnvironment = pdi2w->pEnvironment;
349 if ( !pdi2w->pEnvironment || !*pdi2w->pEnvironment )
350 {
352 }
353
354 pdi->pDriverPath = pdi2w->pDriverPath;
355 pdi->pDataFile = pdi2w->pDataFile;
356 pdi->pConfigFile = pdi2w->pConfigFile;
357 }
358 break;
359
360 default:
362 return FALSE;
363 }
364
365 pDriverContainer.DriverInfo.Level8 = pdi;
366
368 {
369 dwErrorCode = _RpcAddPrinterDriverEx( pName, &pDriverContainer, dwFileCopyFlags );
370 }
372 {
373 dwErrorCode = RpcExceptionCode();
374 ERR("_RpcAddPrinterDriverEx failed with exception code %lu!\n", dwErrorCode);
375 }
377
378 if ( pdi ) HeapFree( GetProcessHeap(), 0, pdi );
379
380 SetLastError(dwErrorCode);
381 return (dwErrorCode == ERROR_SUCCESS);
382}
DWORD _RpcAddPrinterDriverEx(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER *pDriverContainer, DWORD dwFileCopyFlags)
static int multi_sz_lenW(const WCHAR *str)
const WCHAR wszCurrentEnvironment[]
Definition: prtprocenv.h:11
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_SUCCESS
Definition: deptool.c:10
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HANDLE hProcessHeap
Definition: kbswitch.c:37
#define RpcEndExcept
Definition: rpc.h:128
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExcept(expr)
Definition: rpc.h:127
#define RpcExceptionCode()
Definition: rpc.h:132
LPWSTR pDriverPath
Definition: winspool.h:393
LPWSTR pDataFile
Definition: winspool.h:394
LPWSTR pEnvironment
Definition: winspool.h:392
LPWSTR pName
Definition: winspool.h:391
LPWSTR pConfigFile
Definition: winspool.h:395
LPWSTR pMonitorName
Definition: winspool.h:424
LPWSTR pHelpFile
Definition: winspool.h:422
LPWSTR pDependentFiles
Definition: winspool.h:423
LPWSTR pDefaultDataType
Definition: winspool.h:425
LPWSTR pDependentFiles
Definition: winspool.h:454
LPWSTR pszzPreviousNames
Definition: winspool.h:457
LPWSTR pszOEMUrl
Definition: winspool.h:527
FILETIME ftDriverDate
Definition: winspool.h:524
DWORDLONG dwlDriverVersion
Definition: winspool.h:525
LPWSTR pszMfgName
Definition: winspool.h:526
LPWSTR pszHardwareID
Definition: winspool.h:528
LPWSTR pszProvider
Definition: winspool.h:529
WINSPOOL_DRIVER_INFO_8 * Level8
Definition: winspool.idl:607
union _WINSPOOL_DRIVER_CONTAINER::@3436 DriverInfo
uint16_t * PWSTR
Definition: typedefs.h:56
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3554
struct _DRIVER_INFO_6W * PDRIVER_INFO_6W
struct _DRIVER_INFO_3W * PDRIVER_INFO_3W
struct _DRIVER_INFO_4W * PDRIVER_INFO_4W
struct _DRIVER_INFO_8W * PDRIVER_INFO_8W
struct _DRIVER_INFO_2W * PDRIVER_INFO_2W

◆ AddPrinterDriverW()

BOOL WINAPI AddPrinterDriverW ( PWSTR  pName,
DWORD  Level,
PBYTE  pDriverInfo 
)

Definition at line 385 of file printerdrivers.c.

386{
387 TRACE("AddPrinterDriverW(%S, %lu, %p)\n", pName, Level, pDriverInfo);
388 return AddPrinterDriverExW(pName, Level, pDriverInfo, APD_COPY_NEW_FILES);
389}

◆ DeletePrinterDriverA()

BOOL WINAPI DeletePrinterDriverA ( PSTR  pName,
PSTR  pEnvironment,
PSTR  pDriverName 
)

Definition at line 392 of file printerdrivers.c.

393{
394 TRACE("DeletePrinterDriverA(%s, %s, %s)\n", pName, pEnvironment, pDriverName);
395 return DeletePrinterDriverExA(pName, pEnvironment, pDriverName, 0, 0);
396}
BOOL WINAPI DeletePrinterDriverExA(PSTR pName, PSTR pEnvironment, PSTR pDriverName, DWORD dwDeleteFlag, DWORD dwVersionFlag)

◆ DeletePrinterDriverExA()

BOOL WINAPI DeletePrinterDriverExA ( PSTR  pName,
PSTR  pEnvironment,
PSTR  pDriverName,
DWORD  dwDeleteFlag,
DWORD  dwVersionFlag 
)

Definition at line 399 of file printerdrivers.c.

400{
401 DWORD dwErrorCode;
402 UNICODE_STRING NameW, EnvW, DriverW;
403 BOOL ret;
404
405 TRACE("DeletePrinterDriverExA(%s, %s, %s, %lu, %lu)\n", pName, pEnvironment, pDriverName, dwDeleteFlag, dwVersionFlag);
406
407 AsciiToUnicode(&NameW, pName);
408 AsciiToUnicode(&EnvW, pEnvironment);
409 AsciiToUnicode(&DriverW, pDriverName);
410
411 ret = DeletePrinterDriverExW(NameW.Buffer, EnvW.Buffer, DriverW.Buffer, dwDeleteFlag, dwVersionFlag);
412
413 dwErrorCode = GetLastError();
414
415 RtlFreeUnicodeString(&DriverW);
417 RtlFreeUnicodeString(&NameW);
418
419 SetLastError(dwErrorCode);
420 return ret;
421}
BOOL WINAPI DeletePrinterDriverExW(PWSTR pName, PWSTR pEnvironment, PWSTR pDriverName, DWORD dwDeleteFlag, DWORD dwVersionFlag)
wstring AsciiToUnicode(const char *AsciiString)
Definition: tools.cpp:220
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
int ret

Referenced by DeletePrinterDriverA().

◆ DeletePrinterDriverExW()

BOOL WINAPI DeletePrinterDriverExW ( PWSTR  pName,
PWSTR  pEnvironment,
PWSTR  pDriverName,
DWORD  dwDeleteFlag,
DWORD  dwVersionFlag 
)

Definition at line 424 of file printerdrivers.c.

425{
426 DWORD dwErrorCode;
427
428 TRACE("DeletePrinterDriverExW(%S, %S, %S, %lu, %lu)\n", pName, pEnvironment, pDriverName, dwDeleteFlag, dwVersionFlag);
429
430 if ( !pDriverName || !*pDriverName )
431 {
433 return FALSE;
434 }
435
436 if ( !pEnvironment || !*pEnvironment )
437 {
438 pEnvironment = (PWSTR)wszCurrentEnvironment;
439 }
440
441 // Do the RPC call.
443 {
444 dwErrorCode = _RpcDeletePrinterDriverEx(pName, pEnvironment, pDriverName, dwDeleteFlag, dwVersionFlag);
445 }
447 {
448 dwErrorCode = RpcExceptionCode();
449 ERR("_RpcDeletePrinterDriverEx failed with exception code %lu!\n", dwErrorCode);
450 }
452
453 SetLastError(dwErrorCode);
454 return (dwErrorCode == ERROR_SUCCESS);
455
456}
DWORD _RpcDeletePrinterDriverEx(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pDriverName, DWORD dwDeleteFlag, DWORD dwVersionNum)

◆ DeletePrinterDriverW()

BOOL WINAPI DeletePrinterDriverW ( PWSTR  pName,
PWSTR  pEnvironment,
PWSTR  pDriverName 
)

Definition at line 459 of file printerdrivers.c.

460{
461 TRACE("DeletePrinterDriverW(%S, %S, %S)\n", pName, pEnvironment, pDriverName);
462 return DeletePrinterDriverExW(pName, pEnvironment, pDriverName, 0, 0);
463}

◆ EnumPrinterDriversA()

BOOL WINAPI EnumPrinterDriversA ( PSTR  pName,
PSTR  pEnvironment,
DWORD  Level,
PBYTE  pDriverInfo,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 466 of file printerdrivers.c.

467{
468 BOOL ret = FALSE;
469 DWORD dwErrorCode, i;
470 UNICODE_STRING pNameW, pEnvironmentW;
471 PWSTR pwstrNameW, pwstrEnvironmentW;
472 PDRIVER_INFO_1W pdi1w = (PDRIVER_INFO_1W)pDriverInfo;
473 PDRIVER_INFO_8W pdi8w = (PDRIVER_INFO_8W)pDriverInfo;
474
475 FIXME("EnumPrinterDriversA(%s, %s, %lu, %p, %lu, %p, %p)\n", pName, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded, pcReturned);
476
477 pwstrNameW = AsciiToUnicode(&pNameW, pName);
478 pwstrEnvironmentW = AsciiToUnicode(&pEnvironmentW, pEnvironment);
479
480 ret = EnumPrinterDriversW( pwstrNameW, pwstrEnvironmentW, Level, pDriverInfo, cbBuf, pcbNeeded, pcReturned );
481
482 dwErrorCode = GetLastError();
483
484 if (ret)
485 {
486 for ( i = 0; i < *pcReturned; i++ )
487 {
488 switch (Level)
489 {
490 case 1:
491 {
492 dwErrorCode = UnicodeToAnsiInPlace(pdi1w[i].pName);
493 if (dwErrorCode != ERROR_SUCCESS)
494 {
495 goto Cleanup;
496 }
497 break;
498 }
499 case 8:
500 {
501 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pszPrintProcessor);
502 if (dwErrorCode != ERROR_SUCCESS)
503 {
504 goto Cleanup;
505 }
506 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pszVendorSetup);
507 if (dwErrorCode != ERROR_SUCCESS)
508 {
509 goto Cleanup;
510 }
511 dwErrorCode = UnicodeToAnsiZZInPlace(pdi8w[i].pszzColorProfiles);
512 if (dwErrorCode != ERROR_SUCCESS)
513 {
514 goto Cleanup;
515 }
516 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pszInfPath);
517 if (dwErrorCode != ERROR_SUCCESS)
518 {
519 goto Cleanup;
520 }
521 dwErrorCode = UnicodeToAnsiZZInPlace(pdi8w[i].pszzCoreDriverDependencies);
522 if (dwErrorCode != ERROR_SUCCESS)
523 {
524 goto Cleanup;
525 }
526 }
527 case 6:
528 {
529 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pszMfgName);
530 if (dwErrorCode != ERROR_SUCCESS)
531 {
532 goto Cleanup;
533 }
534
535 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pszOEMUrl);
536 if (dwErrorCode != ERROR_SUCCESS)
537 {
538 goto Cleanup;
539 }
540
541 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pszHardwareID);
542 if (dwErrorCode != ERROR_SUCCESS)
543 {
544 goto Cleanup;
545 }
546
547 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pszProvider);
548 if (dwErrorCode != ERROR_SUCCESS)
549 {
550 goto Cleanup;
551 }
552 }
553 case 4:
554 {
555 dwErrorCode = UnicodeToAnsiZZInPlace(pdi8w[i].pszzPreviousNames);
556 if (dwErrorCode != ERROR_SUCCESS)
557 {
558 goto Cleanup;
559 }
560 }
561 case 3:
562 {
563 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pHelpFile);
564 if (dwErrorCode != ERROR_SUCCESS)
565 {
566 goto Cleanup;
567 }
568
569 dwErrorCode = UnicodeToAnsiZZInPlace(pdi8w[i].pDependentFiles);
570 if (dwErrorCode != ERROR_SUCCESS)
571 {
572 goto Cleanup;
573 }
574
575 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pMonitorName);
576 if (dwErrorCode != ERROR_SUCCESS)
577 {
578 goto Cleanup;
579 }
580
581 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pDefaultDataType);
582 if (dwErrorCode != ERROR_SUCCESS)
583 {
584 goto Cleanup;
585 }
586 }
587 case 2:
588 case 5:
589 {
590 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pName);
591 if (dwErrorCode != ERROR_SUCCESS)
592 {
593 goto Cleanup;
594 }
595
596 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pEnvironment);
597 if (dwErrorCode != ERROR_SUCCESS)
598 {
599 goto Cleanup;
600 }
601
602 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pDriverPath);
603 if (dwErrorCode != ERROR_SUCCESS)
604 {
605 goto Cleanup;
606 }
607
608 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pDataFile);
609 if (dwErrorCode != ERROR_SUCCESS)
610 {
611 goto Cleanup;
612 }
613
614 dwErrorCode = UnicodeToAnsiInPlace(pdi8w[i].pConfigFile);
615 if (dwErrorCode != ERROR_SUCCESS)
616 {
617 goto Cleanup;
618 }
619 }
620 }
621 }
622 dwErrorCode = ERROR_SUCCESS;
623 }
624Cleanup:
625 RtlFreeUnicodeString(&pNameW);
626 RtlFreeUnicodeString(&pEnvironmentW);
627 SetLastError(dwErrorCode);
628 FIXME("EnumPrinterDriversA Exit %d Err %d\n",ret,GetLastError());
629 return ret;
630}
#define FIXME(fmt,...)
Definition: debug.h:111
static const WCHAR Cleanup[]
Definition: register.c:80
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD UnicodeToAnsiInPlace(PWSTR pwszField)
Definition: utils.c:28
DWORD UnicodeToAnsiZZInPlace(PWSTR pwszzField)
Definition: utils.c:78
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828
WINBOOL WINAPI EnumPrinterDriversW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
struct _DRIVER_INFO_1W * PDRIVER_INFO_1W

◆ EnumPrinterDriversW()

BOOL WINAPI EnumPrinterDriversW ( PWSTR  pName,
PWSTR  pEnvironment,
DWORD  Level,
PBYTE  pDriverInfo,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 633 of file printerdrivers.c.

634{
635 DWORD dwErrorCode;
636
637 FIXME("EnumPrinterDriversW(%S, %S, %lu, %p, %lu, %p, %p)\n", pName, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded, pcReturned);
638
639 // Dismiss invalid levels already at this point.
640 if (Level < 1 || Level == 7 || Level > 8)
641 {
642 dwErrorCode = ERROR_INVALID_LEVEL;
643 goto Cleanup;
644 }
645
646 if ( !pEnvironment || !*pEnvironment )
647 {
648 pEnvironment = (PWSTR)wszCurrentEnvironment;
649 }
650
651 if (cbBuf && pDriverInfo)
652 ZeroMemory(pDriverInfo, cbBuf);
653
654 // Do the RPC call
656 {
657 dwErrorCode = _RpcEnumPrinterDrivers( pName, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded, pcReturned );
658 }
660 {
661 dwErrorCode = RpcExceptionCode();
662 ERR("_RpcEnumPrinterDrivers failed with exception code %lu!\n", dwErrorCode);
663 }
665
666 if (dwErrorCode == ERROR_SUCCESS)
667 {
668 // Replace relative offset addresses in the output by absolute pointers.
669 ASSERT(Level <= 6 || Level == 8);
670 MarshallUpStructuresArray(cbBuf, pDriverInfo, *pcReturned, pPrinterDriverMarshalling[Level]->pInfo, pPrinterDriverMarshalling[Level]->cbStructureSize, TRUE);
671 }
672
673Cleanup:
674 SetLastError(dwErrorCode); FIXME("EnumPrinterDriversW Exit Err %d\n",dwErrorCode);
675 return (dwErrorCode == ERROR_SUCCESS);
676
677}
DWORD _RpcEnumPrinterDrivers(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pDrivers, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
#define TRUE
Definition: types.h:120
BOOL WINAPI MarshallUpStructuresArray(DWORD cbSize, PVOID pStructuresArray, DWORD cElements, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:202
#define ASSERT(a)
Definition: mode.c:44
static const MARSHALLING * pPrinterDriverMarshalling[]

◆ GetPrinterDriverA()

BOOL WINAPI GetPrinterDriverA ( HANDLE  hPrinter,
LPSTR  pEnvironment,
DWORD  Level,
LPBYTE  pDriverInfo,
DWORD  cbBuf,
LPDWORD  pcbNeeded 
)

Definition at line 680 of file printerdrivers.c.

681{
682 DWORD dwErrorCode;
683 /*
684 * We are mapping multiple different pointers to the same pDriverInfo pointer here so that
685 * we can use the same incoming pointer for different Levels
686 */
687 PDRIVER_INFO_1W pdi1w = (PDRIVER_INFO_1W)pDriverInfo;
688 PDRIVER_INFO_8W pdi8w = (PDRIVER_INFO_8W)pDriverInfo;
689
690 DWORD cch;
691 PWSTR pwszEnvironment = NULL;
692
693 TRACE("GetPrinterDriverA(%p, %s, %lu, %p, %lu, %p)\n", hPrinter, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded);
694
695 // Check for invalid levels here for early error return. Should be 1-6 & 8.
696 if (Level < 1 || Level == 7 || Level > 8)
697 {
698 dwErrorCode = ERROR_INVALID_LEVEL;
699 ERR("Invalid Level! %d\n",Level);
700 goto Cleanup;
701 }
702
703 if (pEnvironment)
704 {
705 // Convert pEnvironment to a Unicode string pwszEnvironment.
706 cch = strlen(pEnvironment);
707
708 pwszEnvironment = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(WCHAR));
709 if (!pwszEnvironment)
710 {
711 dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
712 ERR("HeapAlloc failed!\n");
713 goto Cleanup;
714 }
715
716 MultiByteToWideChar(CP_ACP, 0, pEnvironment, -1, pwszEnvironment, cch + 1);
717 }
718
719 if (!GetPrinterDriverW(hPrinter, pwszEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded))
720 {
721 dwErrorCode = GetLastError();
722 goto Cleanup;
723 }
724
725 // Do Unicode to ANSI conversions for strings based on Level
726 switch (Level)
727 {
728 case 1:
729 {
730 dwErrorCode = UnicodeToAnsiInPlace(pdi1w->pName);
731 if (dwErrorCode != ERROR_SUCCESS)
732 {
733 goto Cleanup;
734 }
735 break;
736 }
737 case 8:
738 {
739 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pszPrintProcessor);
740 if (dwErrorCode != ERROR_SUCCESS)
741 {
742 goto Cleanup;
743 }
744 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pszVendorSetup);
745 if (dwErrorCode != ERROR_SUCCESS)
746 {
747 goto Cleanup;
748 }
749 dwErrorCode = UnicodeToAnsiZZInPlace(pdi8w->pszzColorProfiles);
750 if (dwErrorCode != ERROR_SUCCESS)
751 {
752 goto Cleanup;
753 }
754 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pszInfPath);
755 if (dwErrorCode != ERROR_SUCCESS)
756 {
757 goto Cleanup;
758 }
760 if (dwErrorCode != ERROR_SUCCESS)
761 {
762 goto Cleanup;
763 }
764 }
765 case 6:
766 {
767 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pszMfgName);
768 if (dwErrorCode != ERROR_SUCCESS)
769 {
770 goto Cleanup;
771 }
772
773 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pszOEMUrl);
774 if (dwErrorCode != ERROR_SUCCESS)
775 {
776 goto Cleanup;
777 }
778
779 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pszHardwareID);
780 if (dwErrorCode != ERROR_SUCCESS)
781 {
782 goto Cleanup;
783 }
784
785 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pszProvider);
786 if (dwErrorCode != ERROR_SUCCESS)
787 {
788 goto Cleanup;
789 }
790 }
791 case 4:
792 {
793 dwErrorCode = UnicodeToAnsiZZInPlace(pdi8w->pszzPreviousNames);
794 if (dwErrorCode != ERROR_SUCCESS)
795 {
796 goto Cleanup;
797 }
798 }
799 case 3:
800 {
801 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pHelpFile);
802 if (dwErrorCode != ERROR_SUCCESS)
803 {
804 goto Cleanup;
805 }
806
807 dwErrorCode = UnicodeToAnsiZZInPlace(pdi8w->pDependentFiles);
808 if (dwErrorCode != ERROR_SUCCESS)
809 {
810 goto Cleanup;
811 }
812
813 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pMonitorName);
814 if (dwErrorCode != ERROR_SUCCESS)
815 {
816 goto Cleanup;
817 }
818
819 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pDefaultDataType);
820 if (dwErrorCode != ERROR_SUCCESS)
821 {
822 goto Cleanup;
823 }
824 }
825 case 2:
826 case 5:
827 {
828 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pConfigFile);
829 if (dwErrorCode != ERROR_SUCCESS)
830 {
831 goto Cleanup;
832 }
833 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pDataFile);
834
835 if (dwErrorCode != ERROR_SUCCESS)
836 {
837 goto Cleanup;
838 }
839
840 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pDriverPath);
841 if (dwErrorCode != ERROR_SUCCESS)
842 {
843 goto Cleanup;
844 }
845
846 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pEnvironment);
847 if (dwErrorCode != ERROR_SUCCESS)
848 {
849 goto Cleanup;
850 }
851
852 dwErrorCode = UnicodeToAnsiInPlace(pdi8w->pName);
853 if (dwErrorCode != ERROR_SUCCESS)
854 {
855 goto Cleanup;
856 }
857 }
858 }
859
860 dwErrorCode = ERROR_SUCCESS;
861
862Cleanup:
863 if (pwszEnvironment)
864 {
865 HeapFree(hProcessHeap, 0, pwszEnvironment);
866 }
867
868 SetLastError(dwErrorCode);
869 return (dwErrorCode == ERROR_SUCCESS);
870}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
LPWSTR pName
Definition: winspool.h:373
WINBOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)

Referenced by get_driver_infoA(), PRINTDLG_ChangePrinterA(), PrintDlgA(), and test_GetPrinterDriver().

◆ GetPrinterDriverDirectoryA()

BOOL WINAPI GetPrinterDriverDirectoryA ( PSTR  pName,
PSTR  pEnvironment,
DWORD  Level,
PBYTE  pDriverDirectory,
DWORD  cbBuf,
PDWORD  pcbNeeded 
)

Definition at line 927 of file printerdrivers.c.

928{
929 UNICODE_STRING nameW, environmentW;
930 BOOL ret;
931 DWORD pcbNeededW;
932 INT len = cbBuf * sizeof(WCHAR)/sizeof(CHAR);
933 WCHAR *driverDirectoryW = NULL;
934
935 TRACE("GetPrinterDriverDirectoryA(%s, %s, %d, %p, %d, %p)\n", debugstr_a(pName), debugstr_a(pEnvironment), Level, pDriverDirectory, cbBuf, pcbNeeded);
936
937 if (len) driverDirectoryW = HeapAlloc( GetProcessHeap(), 0, len );
938
939 if (pName)
940 {
942 }
943 else
944 {
945 nameW.Buffer = NULL;
946 }
947 if (pEnvironment)
948 {
949 RtlCreateUnicodeStringFromAsciiz(&environmentW, pEnvironment);
950 }
951 else
952 {
953 environmentW.Buffer = NULL;
954 }
955
956 ret = GetPrinterDriverDirectoryW( nameW.Buffer, environmentW.Buffer, Level, (LPBYTE)driverDirectoryW, len, &pcbNeededW );
957
958 if (ret)
959 {
960 DWORD needed = WideCharToMultiByte( CP_ACP, 0, driverDirectoryW, -1, (LPSTR)pDriverDirectory, cbBuf, NULL, NULL);
961
962 if ( pcbNeeded )
963 *pcbNeeded = needed;
964
965 ret = needed <= cbBuf;
966 }
967 else
968 {
969 if (pcbNeeded) *pcbNeeded = pcbNeededW * sizeof(CHAR)/sizeof(WCHAR);
970 }
971
972 TRACE("required: 0x%x/%d\n", pcbNeeded ? *pcbNeeded : 0, pcbNeeded ? *pcbNeeded : 0);
973
974 HeapFree( GetProcessHeap(), 0, driverDirectoryW );
975 RtlFreeUnicodeString(&environmentW);
977
978 return ret;
979}
#define CHAR(Char)
#define WideCharToMultiByte
Definition: compat.h:111
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
int32_t INT
Definition: typedefs.h:58
WINBOOL WINAPI GetPrinterDriverDirectoryW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverDirectory, DWORD cbBuf, LPDWORD pcbNeeded)
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175

◆ GetPrinterDriverDirectoryW()

BOOL WINAPI GetPrinterDriverDirectoryW ( PWSTR  pName,
PWSTR  pEnvironment,
DWORD  Level,
PBYTE  pDriverDirectory,
DWORD  cbBuf,
PDWORD  pcbNeeded 
)

Definition at line 982 of file printerdrivers.c.

983{
984 DWORD dwErrorCode;
985
986 TRACE("GetPrinterDriverDirectoryW(%S, %S, %lu, %p, %lu, %p)\n", pName, pEnvironment, Level, pDriverDirectory, cbBuf, pcbNeeded);
987
988 if (Level != 1)
989 {
990 dwErrorCode = ERROR_INVALID_LEVEL;
991 goto Cleanup;
992 }
993
994 if ( !pEnvironment || !*pEnvironment )
995 {
996 pEnvironment = (PWSTR)wszCurrentEnvironment;
997 }
998
999 // Do the RPC call.
1001 {
1002 dwErrorCode = _RpcGetPrinterDriverDirectory(pName, pEnvironment, Level, pDriverDirectory, cbBuf, pcbNeeded);
1003 }
1005 {
1006 dwErrorCode = RpcExceptionCode();
1007 ERR("_RpcGetPrinterDriverDirectory failed with exception code %lu!\n", dwErrorCode);
1008 }
1010
1011Cleanup:
1012 SetLastError(dwErrorCode);
1013 return (dwErrorCode == ERROR_SUCCESS);
1014}
DWORD _RpcGetPrinterDriverDirectory(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pDriverDirectory, DWORD cbBuf, DWORD *pcbNeeded)

◆ GetPrinterDriverW()

BOOL WINAPI GetPrinterDriverW ( HANDLE  hPrinter,
LPWSTR  pEnvironment,
DWORD  Level,
LPBYTE  pDriverInfo,
DWORD  cbBuf,
LPDWORD  pcbNeeded 
)

Definition at line 873 of file printerdrivers.c.

874{
875 DWORD dwErrorCode;
876 PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
877
878 TRACE("GetPrinterDriverW(%p, %S, %lu, %p, %lu, %p)\n", hPrinter, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded);
879
880 // Sanity checks.
881 if (!pHandle)
882 {
883 dwErrorCode = ERROR_INVALID_HANDLE;
884 goto Cleanup;
885 }
886
887 // Dismiss invalid levels already at this point.
888 if (Level > 8 || Level == 7 || Level < 1)
889 {
890 dwErrorCode = ERROR_INVALID_LEVEL;
891 goto Cleanup;
892 }
893
894 if ( !pEnvironment || !*pEnvironment )
895 {
896 pEnvironment = (PWSTR)wszCurrentEnvironment;
897 }
898
899 if (cbBuf && pDriverInfo)
900 ZeroMemory(pDriverInfo, cbBuf);
901
902 // Do the RPC call
904 {
905 dwErrorCode = _RpcGetPrinterDriver(pHandle->hPrinter, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded);
906 }
908 {
909 dwErrorCode = RpcExceptionCode();
910 ERR("_RpcGetPrinterDriver failed with exception code %lu!\n", dwErrorCode);
911 }
913
914 if (dwErrorCode == ERROR_SUCCESS)
915 {
916 // Replace relative offset addresses in the output by absolute pointers.
917 ASSERT(Level <= 6 || Level == 8);
918 MarshallUpStructure(cbBuf, pDriverInfo, pPrinterDriverMarshalling[Level]->pInfo, pPrinterDriverMarshalling[Level]->cbStructureSize, TRUE);
919 }
920
921Cleanup:
922 SetLastError(dwErrorCode);
923 return (dwErrorCode == ERROR_SUCCESS);
924}
DWORD _RpcGetPrinterDriver(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pEnvironment, DWORD Level, BYTE *pDriver, DWORD cbBuf, DWORD *pcbNeeded)
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
BOOL WINAPI MarshallUpStructure(DWORD cbSize, PVOID pStructure, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:137
HANDLE hPrinter
Definition: precomp.h:50
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE

Referenced by get_driver_infoW(), LoadPrinterDriver(), pagesetup_change_printer(), PRINTDLG_ChangePrinterW(), and PrintDlgW().

◆ multi_sz_lenA()

static int multi_sz_lenA ( const char str)
static

Definition at line 13 of file printerdrivers.c.

14{
15 const char *ptr = str;
16 if(!str) return 0;
17 do
18 {
19 ptr += lstrlenA(ptr) + 1;
20 } while(*ptr);
21
22 return ptr - str + 1;
23}
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str

Referenced by AddPrinterDriverExA().

◆ multi_sz_lenW()

static int multi_sz_lenW ( const WCHAR str)
static

Definition at line 25 of file printerdrivers.c.

26{
27 const WCHAR *ptr = str;
28 if (!str) return 0;
29 do
30 {
31 ptr += lstrlenW(ptr) + 1;
32 } while (*ptr);
33
34 return (ptr - str + 1);
35}
#define lstrlenW
Definition: compat.h:750

Referenced by AddPrinterDriverExW(), and myAddPrinterDriverEx().

Variable Documentation

◆ wszCurrentEnvironment