Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

614 lines
16 KiB

  1. /*++
  2. Copyright (c) 1990-2001 Microsoft Corporation
  3. Module Name:
  4. WinDDIUI.h
  5. Abstract:
  6. Header file for the UI portion of printer drivers.
  7. Revision History:
  8. --*/
  9. #ifndef _WINDDIUI_
  10. #define _WINDDIUI_
  11. #include <compstui.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. //
  16. // DrvDevicePropertySheets replace previous version of PrinterProperties
  17. //
  18. LONG WINAPI
  19. DrvDevicePropertySheets(
  20. PPROPSHEETUI_INFO pPSUIInfo,
  21. LPARAM lParam
  22. );
  23. typedef struct _DEVICEPROPERTYHEADER {
  24. WORD cbSize;
  25. WORD Flags;
  26. HANDLE hPrinter;
  27. LPTSTR pszPrinterName;
  28. } DEVICEPROPERTYHEADER, *PDEVICEPROPERTYHEADER;
  29. #define DPS_NOPERMISSION 0x0001
  30. //
  31. // For document properties replace DocumentProperties.
  32. //
  33. // Note: if pPSUIInfo is NULL then the call need not to display any dialog
  34. // boxes (Ignored the DC_PROMPT bit in the fMode, the lParam in this case
  35. // is a pointer to DOCUMENTPROPERTYHEADER
  36. //
  37. LONG WINAPI
  38. DrvDocumentPropertySheets(
  39. PPROPSHEETUI_INFO pPSUIInfo,
  40. LPARAM lParam
  41. );
  42. typedef struct _DOCUMENTPROPERTYHEADER {
  43. WORD cbSize;
  44. WORD Reserved;
  45. HANDLE hPrinter;
  46. LPTSTR pszPrinterName;
  47. PDEVMODE pdmIn;
  48. PDEVMODE pdmOut;
  49. DWORD cbOut;
  50. DWORD fMode;
  51. } DOCUMENTPROPERTYHEADER, *PDOCUMENTPROPERTYHEADER;
  52. #define DM_ADVANCED 0x10
  53. #define DM_NOPERMISSION 0x20
  54. #define DM_USER_DEFAULT 0x40
  55. // Devmode conversion function used by GetPrinter and SetPrinter
  56. BOOL WINAPI
  57. DrvConvertDevMode(
  58. LPTSTR pPrinterName,
  59. PDEVMODE pdmIn,
  60. PDEVMODE pdmOut,
  61. PLONG pcbNeeded,
  62. DWORD fMode
  63. );
  64. #define CDM_CONVERT 0x01
  65. #define CDM_CONVERT351 0x02
  66. #define CDM_DRIVER_DEFAULT 0x04
  67. //
  68. // This is for DevQueryPrintEx()
  69. //
  70. typedef struct _DEVQUERYPRINT_INFO {
  71. WORD cbSize; // size of this structure in bytes
  72. WORD Level; // Level of this info, 1 for this version
  73. HANDLE hPrinter; // handle to the printer for the query
  74. DEVMODE *pDevMode; // pointer to the DEVMODE for this job.
  75. LPTSTR pszErrorStr; // pointer to the error string buffer.
  76. DWORD cchErrorStr; // count characters of pwErrorStr passed.
  77. DWORD cchNeeded; // count characters of pwErrorStr needed.
  78. } DEVQUERYPRINT_INFO, *PDEVQUERYPRINT_INFO;
  79. BOOL WINAPI
  80. DevQueryPrintEx(
  81. PDEVQUERYPRINT_INFO pDQPInfo
  82. );
  83. //
  84. // This for the DrvUpgradePrinter
  85. //
  86. typedef struct _DRIVER_UPGRADE_INFO_1 {
  87. LPTSTR pPrinterName;
  88. LPTSTR pOldDriverDirectory;
  89. } DRIVER_UPGRADE_INFO_1, *PDRIVER_UPGRADE_INFO_1;
  90. typedef struct _DRIVER_UPGRADE_INFO_2 {
  91. LPTSTR pPrinterName;
  92. LPTSTR pOldDriverDirectory;
  93. DWORD cVersion;
  94. LPTSTR pName;
  95. LPTSTR pEnvironment;
  96. LPTSTR pDriverPath;
  97. LPTSTR pDataFile;
  98. LPTSTR pConfigFile;
  99. LPTSTR pHelpFile;
  100. LPTSTR pDependentFiles;
  101. LPTSTR pMonitorName;
  102. LPTSTR pDefaultDataType;
  103. LPTSTR pszzPreviousNames;
  104. } DRIVER_UPGRADE_INFO_2, *PDRIVER_UPGRADE_INFO_2;
  105. BOOL WINAPI
  106. DrvUpgradePrinter(
  107. DWORD Level,
  108. LPBYTE pDriverUpgradeInfo
  109. );
  110. //
  111. // DrvDocumentEvent
  112. //
  113. //
  114. // Defines and proto-types for hooking GDI printer management functions
  115. //
  116. // return values: -1 means error, 0 means not supported function
  117. //
  118. // CreateDCPre must return > 0 or none of the others will be called.
  119. //
  120. //
  121. // CREATEDCPRE
  122. // return failure from CreateDC if this fails, CREATEDCPOST not called
  123. // bIC - TRUE if came from CreateIC
  124. // output devmode - this is the devmode that actualy gets passed to the
  125. // server side driver. Any data needed in EnablePDEV should be passed
  126. // as part of the DriverExtra.
  127. //
  128. // CREATEDCPOST
  129. // return value is ignored
  130. // the hdc will be 0 if something failed since CREATEDCPRE
  131. // The input buffer contains a pointer to the devmode returned in the
  132. // CREATEDCPRE output buffer
  133. //
  134. // RESETDCPRE
  135. // return failure from ResetDC if this fails, CREATEDCPOST not called
  136. //
  137. // RESETDCPOST
  138. // return value is ignored
  139. //
  140. // STARTDOCPRE
  141. // return failure form StartDoc if this fails, driver not called
  142. //
  143. // STARTDOCPOST
  144. // return failure form StartDoc if this fails, driver already called.
  145. // AbortDoc() called.
  146. //
  147. // STARTPAGE
  148. // return failure form EndPage if this fails, driver not called
  149. //
  150. // ENDPAGE
  151. // return value is ignored, DrvEndPage always called
  152. //
  153. // ENDDOCPRE
  154. // return value is ignored, DrvEndDoc always called
  155. //
  156. // ENDDOCPOST
  157. // return value is ignored, DrvEndDoc has alreadybeen called
  158. //
  159. // ABORTDOC
  160. // return value is ignored
  161. //
  162. // DELETEDC
  163. // return value is ignored
  164. //
  165. // EXTESCAPE
  166. // return value is ignored
  167. // The input buffer includes the ExtEscape escape value, size of input
  168. // buffer to ExtEscape and the input buffer passed in.
  169. // The output buffer is just the buffer that was passed to ExtEscape
  170. //
  171. // DOCUMENTEVENT_SPOOLED
  172. // This flag is added to the iEsc value if the document is being spooled
  173. // to a metafile rather than going direct. Note that if this bit is set
  174. //
  175. //
  176. #define DOCUMENTEVENT_EVENT(iEsc) (LOWORD(iEsc))
  177. #define DOCUMENTEVENT_FLAGS(iEsc) (HIWORD(iEsc))
  178. typedef struct _DOCEVENT_FILTER {
  179. UINT cbSize;
  180. UINT cElementsAllocated;
  181. UINT cElementsNeeded;
  182. UINT cElementsReturned;
  183. DWORD aDocEventCall[ANYSIZE_ARRAY];
  184. } DOCEVENT_FILTER, *PDOCEVENT_FILTER;
  185. //
  186. // Add structures usded for each DocumentEvent calls
  187. //
  188. typedef struct _DOCEVENT_CREATEDCPRE {
  189. PWSTR pszDriver;
  190. PWSTR pszDevice;
  191. PDEVMODEW pdm;
  192. BOOL bIC;
  193. } DOCEVENT_CREATEDCPRE, *PDCEVENT_CREATEDCPRE;
  194. typedef struct _DOCEVENT_ESCAPE {
  195. int iEscape;
  196. int cjInput;
  197. PVOID pvInData;
  198. } DOCEVENT_ESCAPE, *PDOCEVENT_ESCAPE;
  199. //
  200. // Escape codes for DrvDocumentEvent
  201. //
  202. #define DOCUMENTEVENT_FIRST 1 // Inclusive lower bound
  203. #define DOCUMENTEVENT_CREATEDCPRE 1 // in-pszDriver, pszDevice, pdm, bIC, out-ppdm
  204. #define DOCUMENTEVENT_CREATEDCPOST 2 // in-ppdm
  205. #define DOCUMENTEVENT_RESETDCPRE 3 // in-pszDriver, pszDevice, pdm, out-ppdm
  206. #define DOCUMENTEVENT_RESETDCPOST 4 // in-ppdm
  207. #define DOCUMENTEVENT_STARTDOC 5 // none
  208. #define DOCUMENTEVENT_STARTDOCPRE 5 // none
  209. #define DOCUMENTEVENT_STARTPAGE 6 // none
  210. #define DOCUMENTEVENT_ENDPAGE 7 // none
  211. #define DOCUMENTEVENT_ENDDOC 8 // none
  212. #define DOCUMENTEVENT_ENDDOCPRE 8 // none
  213. #define DOCUMENTEVENT_ABORTDOC 9 // none
  214. #define DOCUMENTEVENT_DELETEDC 10 // none
  215. #define DOCUMENTEVENT_ESCAPE 11 // in-iEsc, cjInBuf, inBuf, out-outBuf
  216. #define DOCUMENTEVENT_ENDDOCPOST 12 // none
  217. #define DOCUMENTEVENT_STARTDOCPOST 13 // none
  218. #define DOCUMENTEVENT_QUERYFILTER 14 // none
  219. #define DOCUMENTEVENT_LAST 15 // Non-inclusive upper bound
  220. #define DOCUMENTEVENT_SPOOLED 0x10000
  221. //
  222. // Return values for DrvDocumentEvent
  223. //
  224. #define DOCUMENTEVENT_SUCCESS 1
  225. #define DOCUMENTEVENT_UNSUPPORTED 0
  226. #define DOCUMENTEVENT_FAILURE -1
  227. int WINAPI
  228. DrvDocumentEvent(
  229. HANDLE hPrinter,
  230. HDC hdc,
  231. int iEsc,
  232. ULONG cbIn,
  233. PVOID pvIn,
  234. ULONG cbOut,
  235. PVOID pvOut
  236. );
  237. //
  238. // DrvPrinterEvent
  239. //
  240. //
  241. // DrvPrinterEvent are called by the print subsystem when events
  242. // happen that might be of interest to a printer driver
  243. // The only event which should be implemented in the driver
  244. // is PRITNER_EVENT_INITIALIZE so that default settings are created
  245. // for the printer.
  246. //
  247. // PRINTER_EVENT_CONFIGURATION_CHANGE
  248. // Reserve it for future use.Xerox is already using it.
  249. //
  250. // PRINTER_EVENT_ADD_CONNECTION
  251. // return value ignored
  252. // Called after a successful AddPrinterConnection API
  253. // in the context of the calling app
  254. // lParam NULL
  255. //
  256. // PRINTER_EVENT_DELETE_CONNECTION
  257. // return value ignored
  258. // Called Before DeletePrinterConnect API
  259. // in the context of the calling app
  260. // lParam NULL
  261. //
  262. // PRINTER_EVENT_INITIALIZE
  263. // Called when a printer is created for the driver to
  264. // initialize its registry settings
  265. // Called in the spooler process
  266. // lParam NULL
  267. //
  268. // PRINTER_EVENT_DELETE
  269. // Called when a printer is about to be deleted
  270. // Called in the spooler process
  271. // lParam NULL
  272. //
  273. // PRINTER_EVENT_CACHE_REFRESH
  274. // return value ignored
  275. // called in spooler process
  276. // No UI
  277. // called when spooler detects that something has
  278. // changed in the workstaion cache or when establishing
  279. // the cache.
  280. // allows driver to update any private cache data
  281. // ( such as font files etc. )
  282. //
  283. // PRINTER_EVENT_CACHE_DELETE
  284. // return value ignored
  285. // called in spooler process
  286. // No UI
  287. // called when spooler is deleting a cached printer
  288. // allows printer driver to delete anything it has
  289. // cached
  290. //
  291. // PRINTER_EVENT_ATTRIBUTES_CHANGED
  292. // return value ignored
  293. // No UI
  294. // Called when the printer attribute bits for a given
  295. // printer have changed. Allows the driver to respond
  296. // appropriately.
  297. // lParam is a pointer to a PRINTER_EVENT_ATTRIBUTES_INFO
  298. // structure.
  299. //
  300. // PRINTER_EVENT_FLAG_NO_UI
  301. // Do not bring up UI when this flag it ON
  302. //
  303. //
  304. // DrvPrinterEvent DriverEvent code
  305. //
  306. #define PRINTER_EVENT_CONFIGURATION_CHANGE 0
  307. #define PRINTER_EVENT_ADD_CONNECTION 1
  308. #define PRINTER_EVENT_DELETE_CONNECTION 2
  309. #define PRINTER_EVENT_INITIALIZE 3
  310. #define PRINTER_EVENT_DELETE 4
  311. #define PRINTER_EVENT_CACHE_REFRESH 5
  312. #define PRINTER_EVENT_CACHE_DELETE 6
  313. #define PRINTER_EVENT_ATTRIBUTES_CHANGED 7
  314. //
  315. // DrvPrinterEvent Flags
  316. //
  317. #define PRINTER_EVENT_FLAG_NO_UI 0x00000001
  318. //
  319. // lParam of PRINTER_EVENT_ATTRIBUTES_CHANGED points to this structure.
  320. //
  321. typedef struct _PRINTER_EVENT_ATTRIBUTES_INFO {
  322. DWORD cbSize;
  323. DWORD dwOldAttributes;
  324. DWORD dwNewAttributes;
  325. } PRINTER_EVENT_ATTRIBUTES_INFO, *PPRINTER_EVENT_ATTRIBUTES_INFO;
  326. BOOL WINAPI
  327. DrvPrinterEvent(
  328. LPWSTR pPrinterName,
  329. int DriverEvent,
  330. DWORD Flags,
  331. LPARAM lParam
  332. );
  333. //
  334. // DrvDriverEvent is called when any version of the printer driver is deleted.
  335. //
  336. #define DRIVER_EVENT_INITIALIZE 0x00000001
  337. #define DRIVER_EVENT_DELETE 0x00000002
  338. BOOL WINAPI
  339. DrvDriverEvent(
  340. DWORD dwDriverEvent,
  341. DWORD dwLevel,
  342. LPBYTE pDriverInfo,
  343. LPARAM lParam
  344. );
  345. // Print processor capabilities for the driver.
  346. #define BORDER_PRINT 0x00000000 // default
  347. #define NO_BORDER_PRINT 0x00000001
  348. #define BOOKLET_PRINT 0x00000002
  349. #define NO_COLOR_OPTIMIZATION 0x00000000 // default
  350. #define COLOR_OPTIMIZATION 0x00000001
  351. typedef struct _ATTRIBUTE_INFO_1 {
  352. DWORD dwJobNumberOfPagesPerSide;
  353. DWORD dwDrvNumberOfPagesPerSide;
  354. DWORD dwNupBorderFlags;
  355. DWORD dwJobPageOrderFlags;
  356. DWORD dwDrvPageOrderFlags;
  357. DWORD dwJobNumberOfCopies;
  358. DWORD dwDrvNumberOfCopies;
  359. } ATTRIBUTE_INFO_1, *PATTRIBUTE_INFO_1;
  360. typedef struct _ATTRIBUTE_INFO_2 {
  361. DWORD dwJobNumberOfPagesPerSide;
  362. DWORD dwDrvNumberOfPagesPerSide;
  363. DWORD dwNupBorderFlags;
  364. DWORD dwJobPageOrderFlags;
  365. DWORD dwDrvPageOrderFlags;
  366. DWORD dwJobNumberOfCopies;
  367. DWORD dwDrvNumberOfCopies;
  368. DWORD dwColorOptimization; // Added for monochrome optimization
  369. } ATTRIBUTE_INFO_2, *PATTRIBUTE_INFO_2;
  370. #ifndef __ATTRIBUTE_INFO_3__
  371. #define __ATTRIBUTE_INFO_3__
  372. typedef struct _ATTRIBUTE_INFO_3 {
  373. DWORD dwJobNumberOfPagesPerSide;
  374. DWORD dwDrvNumberOfPagesPerSide;
  375. DWORD dwNupBorderFlags;
  376. DWORD dwJobPageOrderFlags;
  377. DWORD dwDrvPageOrderFlags;
  378. DWORD dwJobNumberOfCopies;
  379. DWORD dwDrvNumberOfCopies;
  380. DWORD dwColorOptimization; // Added for monochrome optimization
  381. short dmPrintQuality; // Added for monochrome optimization
  382. short dmYResolution; // Added for monochrome optimization
  383. } ATTRIBUTE_INFO_3, *PATTRIBUTE_INFO_3;
  384. #endif
  385. //
  386. // DrvQueryJobAttributes is called by the spooler(print processor) to get information
  387. // about the printing options used with the job. These options include N-up and reverse
  388. // order printing.
  389. //
  390. BOOL WINAPI
  391. DrvQueryJobAttributes(
  392. HANDLE hPrinter,
  393. PDEVMODE pDevMode,
  394. DWORD dwLevel,
  395. LPBYTE lpAttributeInfo
  396. );
  397. //
  398. // DrvQueryColorProfile is called by the GDI (graphics device interface) to get information
  399. // about the default color profile for the given DEVMODE, used with ICM (image color
  400. // management).
  401. //
  402. BOOL WINAPI
  403. DrvQueryColorProfile(
  404. HANDLE hPrinter,
  405. PDEVMODEW pdevmode,
  406. ULONG ulQueryMode,
  407. VOID *pvProfileData,
  408. ULONG *pcbProfileData,
  409. FLONG *pflProfileData
  410. );
  411. // The value for ulQueryMode
  412. #define QCP_DEVICEPROFILE 0x0000
  413. #define QCP_SOURCEPROFILE 0x0001
  414. // The flags for pflProfileData.
  415. #define QCP_PROFILEMEMORY 0x0001 // The pvProfileData points the color profile data itself.
  416. #define QCP_PROFILEDISK 0x0002 // The pvProfileData points the color profile file name in Unicode.
  417. //
  418. // User Mode Printer Driver DLL,
  419. //
  420. // Note on hPrinter passed into DrvSplStartDoc() and subsequent
  421. // DrvSplxxx calls
  422. //
  423. //
  424. // A. If you have DrvSplxxxx calls in separate DLL and link it with
  425. // spoolss.lib.
  426. //
  427. // * The hPrinter will be valid for any call to the spooler, such as
  428. // WritePrinter(), GetPrinterData()
  429. //
  430. // * To do this you must
  431. //
  432. // 1. Have separate DLL for all DrvSplxxx functions.
  433. // 2. Put this DLL name into your dependency files (inf).
  434. // 3. link to spoolss.lib rather than winspool.lib
  435. // 4. Use SetPrinterData() with SPLPRINTER_USER_MODE_PRINTER_DRIVER
  436. // as key name, and this DLL name as data.
  437. // 5. Call any spooler functions linked from spoolss.lib
  438. //
  439. //
  440. //
  441. // B. If you have DrvSplxxx calls located in your printer driver UI DLL and
  442. // linked with winspool.lib
  443. //
  444. // * The hPrinter is NOT valid for any spooler calls, such as
  445. // WritePrinter(), GetPrinterData() from within the DrvSplxxx driver
  446. // functions.
  447. //
  448. // * To do any spooler call from inside of DrvSplxxxx function you must
  449. // do the following
  450. //
  451. // 1. hSpoolSS = LoadLibrary("spoolss.dll");
  452. // 2. pfn = GetProcAddress("WritePrinter") or whatever the spooler
  453. // functions you wish to call
  454. // 3. Call the pfn function pointer returned from GetProcAddress()
  455. // 4. FreeLibrary(hSpoolSS);
  456. //
  457. //
  458. // The A method is recommended.
  459. //
  460. //
  461. // If a UserModePrinterDriver DLL is created the following routines are
  462. // required or optional
  463. //
  464. // Required Routines
  465. // DrvSplStartDoc
  466. // DrvSplWritePrinter
  467. // DrvSplEndDoc
  468. // DrvSplClose
  469. //
  470. //
  471. // Optional Routines
  472. // DrvSplStart
  473. // DrvSplEndPage
  474. // DrvSplAbort
  475. //
  476. //
  477. HANDLE WINAPI
  478. DrvSplStartDoc(
  479. HANDLE hPrinter,
  480. DWORD JobId
  481. );
  482. BOOL WINAPI
  483. DrvSplWritePrinter(
  484. HANDLE hDriver,
  485. LPVOID pBuf,
  486. DWORD cbBuf,
  487. LPDWORD pcWritten
  488. );
  489. VOID WINAPI
  490. DrvSplEndDoc(
  491. HANDLE hDriver
  492. );
  493. VOID WINAPI
  494. DrvSplClose(
  495. HANDLE hDriver
  496. );
  497. BOOL WINAPI
  498. DrvSplStartPage(
  499. HANDLE hDriver
  500. );
  501. BOOL WINAPI
  502. DrvSplEndPage(
  503. HANDLE hDriver
  504. );
  505. VOID WINAPI
  506. DrvSplAbort(
  507. HANDLE hDriver
  508. );
  509. DWORD
  510. DrvSplDeviceCaps(
  511. HANDLE hPrinter,
  512. PWSTR pszDeviceName,
  513. WORD Capability,
  514. PVOID pOutput,
  515. DWORD cchBufSize,
  516. PDEVMODE pDevmode
  517. );
  518. DWORD
  519. DrvDeviceCapabilities(
  520. HANDLE hPrinter,
  521. PWSTR pszDeviceName,
  522. WORD Capability,
  523. PVOID pOutput,
  524. PDEVMODE pDevmode
  525. );
  526. //
  527. // Printer Attribute
  528. // Use with SetPrinterData to define UMPD.DLL
  529. //
  530. #define SPLPRINTER_USER_MODE_PRINTER_DRIVER TEXT("SPLUserModePrinterDriver")
  531. #ifdef __cplusplus
  532. }
  533. #endif
  534. #endif /* !_WINDDIUI_ */