Windows NT 4.0 source code leak
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.

434 lines
11 KiB

4 years ago
  1. /********************************************************************
  2. WinDDiUi.h -- Header file for the UI portion of printer drivers.
  3. Copyright (c) 1995 1996, Microsoft Corp.
  4. All rights reserved.
  5. ********************************************************************/
  6. #ifndef _WINDDIUI_
  7. #define _WINDDIUI_
  8. #include <compstui.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. //
  13. // DrvDevicePropertySheets replace previous version of PrinterProperties
  14. //
  15. LONG
  16. DrvDevicePropertySheets(
  17. PPROPSHEETUI_INFO pPSUIInfo,
  18. LPARAM lParam
  19. );
  20. typedef struct _DEVICEPROPERTYHEADER {
  21. WORD cbSize;
  22. WORD Flags;
  23. HANDLE hPrinter;
  24. LPTSTR pszPrinterName;
  25. } DEVICEPROPERTYHEADER, *PDEVICEPROPERTYHEADER;
  26. #define DPS_NOPERMISSION 0x0001
  27. //
  28. // For document properties replace DocumentProperties.
  29. //
  30. // Note: if pPSUIInfo is NULL then the call need not to display any dialog
  31. // boxes (Ignored the DC_PROMPT bit in the fMode, the lParam in this case
  32. // is a pointer to DOCUMENTPROPERTYHEADER
  33. //
  34. LONG
  35. DrvDocumentPropertySheets(
  36. PPROPSHEETUI_INFO pPSUIInfo,
  37. LPARAM lParam
  38. );
  39. typedef struct _DOCUMENTPROPERTYHEADER {
  40. WORD cbSize;
  41. WORD Reserved;
  42. HANDLE hPrinter;
  43. LPTSTR pszPrinterName;
  44. PDEVMODE pdmIn;
  45. PDEVMODE pdmOut;
  46. DWORD cbOut;
  47. DWORD fMode;
  48. } DOCUMENTPROPERTYHEADER, *PDOCUMENTPROPERTYHEADER;
  49. #define DM_ADVANCED 0x10
  50. #define DM_NOPERMISSION 0x20
  51. #define DM_USER_DEFAULT 0x40
  52. // Devmode conversion function used by GetPrinter and SetPrinter
  53. BOOL
  54. DrvConvertDevMode(
  55. LPTSTR pPrinterName,
  56. PDEVMODE pdmIn,
  57. PDEVMODE pdmOut,
  58. PLONG pcbNeeded,
  59. DWORD fMode
  60. );
  61. #define CDM_CONVERT 0x01
  62. #define CDM_CONVERT351 0x02
  63. #define CDM_DRIVER_DEFAULT 0x04
  64. //
  65. // This is for DevQueryPrintEx()
  66. //
  67. typedef struct _DEVQUERYPRINT_INFO {
  68. WORD cbSize; // size of this structure in bytes
  69. WORD Level; // Level of this info, 1 for this version
  70. HANDLE hPrinter; // handle to the printer for the query
  71. DEVMODE *pDevMode; // pointer to the DEVMODE for this job.
  72. LPTSTR pszErrorStr; // pointer to the error string buffer.
  73. DWORD cchErrorStr; // count characters of pwErrorStr passed.
  74. DWORD cchNeeded; // count characters of pwErrorStr needed.
  75. } DEVQUERYPRINT_INFO, *PDEVQUERYPRINT_INFO;
  76. BOOL
  77. DevQueryPrintEx(
  78. PDEVQUERYPRINT_INFO pDQPInfo
  79. );
  80. //
  81. // This for the DrvUpgradePrinter
  82. //
  83. typedef struct _DRIVER_UPGRADE_INFO_1 {
  84. LPTSTR pPrinterName;
  85. LPTSTR pOldDriverDirectory;
  86. } DRIVER_UPGRADE_INFO_1, *PDRIVER_UPGRADE_INFO_1;
  87. BOOL
  88. DrvUpgradePrinter(
  89. DWORD Level,
  90. LPBYTE pDriverUpgradeInfo
  91. );
  92. //
  93. // DrvDocumentEvent
  94. //
  95. //
  96. // Defines and proto-types for hooking GDI printer management functions
  97. //
  98. // return values: -1 means error, 0 means not supported function
  99. //
  100. // CreateDCPre must return > 0 or none of the others will be called.
  101. //
  102. //
  103. // CREATEDCPRE
  104. // return failure from CreateDC if this fails, CREATEDCPOST not called
  105. // bIC - TRUE if came from CreateIC
  106. // output devmode - this is the devmode that actualy gets passed to the
  107. // server side driver. Any data needed in EnablePDEV should be passed
  108. // as part of the DriverExtra.
  109. //
  110. // CREATEDCPOST
  111. // return value is ignored
  112. // the hdc will be 0 if something failed since CREATEDCPRE
  113. // The input buffer contains a pointer to the devmode returned in the
  114. // CREATEDCPRE output buffer
  115. //
  116. // RESETDCPRE
  117. // return failure from ResetDC if this fails, CREATEDCPOST not called
  118. //
  119. // RESETDCPOST
  120. // return value is ignored
  121. //
  122. // STARTDOCPRE
  123. // return failure form StartDoc if this fails, driver not called
  124. //
  125. // STARTDOCPOST
  126. // return failure form StartDoc if this fails, driver already called.
  127. // AbortDoc() called.
  128. //
  129. // STARTPAGE
  130. // return failure form EndPage if this fails, driver not called
  131. //
  132. // ENDPAGE
  133. // return value is ignored, DrvEndPage always called
  134. //
  135. // ENDDOCPRE
  136. // return value is ignored, DrvEndDoc always called
  137. //
  138. // ENDDOCPOST
  139. // return value is ignored, DrvEndDoc has alreadybeen called
  140. //
  141. // ABORTDOC
  142. // return value is ignored
  143. //
  144. // DELETEDC
  145. // return value is ignored
  146. //
  147. // EXTESCAPE
  148. // return value is ignored
  149. // The input buffer includes the ExtEscape escape value, size of input
  150. // buffer to ExtEscape and the input buffer passed in.
  151. // The output buffer is just the buffer that was passed to ExtEscape
  152. //
  153. // DOCUMENTEVENT_SPOOLED
  154. // This flag is added to the iEsc value if the document is being spooled
  155. // to a metafile rather than going direct. Note that if this bit is set
  156. //
  157. //
  158. #define DOCUMENTEVENT_EVENT(iEsc) (LOWORD(iEsc))
  159. #define DOCUMENTEVENT_FLAGS(iEsc) (HIWORD(iEsc))
  160. //
  161. // Escape codes for DrvDocumentEvent
  162. //
  163. #define DOCUMENTEVENT_FIRST 1 // Inclusive lower bound
  164. #define DOCUMENTEVENT_CREATEDCPRE 1 // in-pszDriver, pszDevice, pdm, bIC, out-ppdm
  165. #define DOCUMENTEVENT_CREATEDCPOST 2 // in-ppdm
  166. #define DOCUMENTEVENT_RESETDCPRE 3 // in-pszDriver, pszDevice, pdm, out-ppdm
  167. #define DOCUMENTEVENT_RESETDCPOST 4 // in-ppdm
  168. #define DOCUMENTEVENT_STARTDOC 5 // none
  169. #define DOCUMENTEVENT_STARTDOCPRE 5 // none
  170. #define DOCUMENTEVENT_STARTPAGE 6 // none
  171. #define DOCUMENTEVENT_ENDPAGE 7 // none
  172. #define DOCUMENTEVENT_ENDDOC 8 // none
  173. #define DOCUMENTEVENT_ENDDOCPRE 8 // none
  174. #define DOCUMENTEVENT_ABORTDOC 9 // none
  175. #define DOCUMENTEVENT_DELETEDC 10 // none
  176. #define DOCUMENTEVENT_ESCAPE 11 // in-iEsc, cjInBuf, inBuf, out-outBuf
  177. #define DOCUMENTEVENT_ENDDOCPOST 12 // none
  178. #define DOCUMENTEVENT_STARTDOCPOST 13 // none
  179. #define DOCUMENTEVENT_LAST 14 // Non-inclusive upper bound
  180. #define DOCUMENTEVENT_SPOOLED 0x10000
  181. //
  182. // Return values for DrvDocumentEvent
  183. //
  184. #define DOCUMENTEVENT_SUCCESS 1
  185. #define DOCUMENTEVENT_UNSUPPORTED 0
  186. #define DOCUMENTEVENT_FAILURE -1
  187. int
  188. DrvDocumentEvent(
  189. HANDLE hPrinter,
  190. HDC hdc,
  191. int iEsc,
  192. ULONG cbIn,
  193. PULONG pbIn,
  194. ULONG cbOut,
  195. PULONG pbOut
  196. );
  197. //
  198. // DrvPrinterEvent
  199. //
  200. //
  201. // DrvPrinterEvent are called by the print subsystem when events
  202. // happen that might be of interest to a printer driver
  203. // The only event which should be implemented in the driver
  204. // is PRITNER_EVENT_INITIALIZE so that default settings are created
  205. // for the printer.
  206. //
  207. // PRINTER_EVENT_ADD_CONNECTION
  208. // return value ignored
  209. // Called after a successful AddPrinterConnection API
  210. // in the context of the calling app
  211. // lParam NULL
  212. //
  213. // PRINTER_EVENT_DELETE_CONNECTION
  214. // return value ignored
  215. // Called Before DeletePrinterConnect API
  216. // in the context of the calling app
  217. // lParam NULL
  218. //
  219. // PRINTER_EVENT_INITIALIZE
  220. // Called when a printer is created for the driver to
  221. // initialize its registry settings
  222. // Called in the spooler process
  223. // lParam NULL
  224. //
  225. // PRINTER_EVENT_DELETE
  226. // Called when a printer is about to be deleted
  227. // Called in the spooler process
  228. // lParam NULL
  229. //
  230. // PRINTER_EVENT_CACHE_REFRESH
  231. // return value ignored
  232. // called in spooler process
  233. // No UI
  234. // called when spooler detects that something has
  235. // changed in the workstaion cache or when establishing
  236. // the cache.
  237. // allows driver to update any private cache data
  238. // ( such as font files etc. )
  239. //
  240. // PRINTER_EVENT_CACHE_DELETE
  241. // return value ignored
  242. // called in spooler process
  243. // No UI
  244. // called when spooler is deleting a cached printer
  245. // allows printer driver to delete anything it has
  246. // cached
  247. //
  248. // PRINTER_EVENT_FLAG_NO_UI
  249. // Do not bring up UI when this flag it ON
  250. //
  251. //
  252. // DrvPrinterEvent DriverEvent code
  253. //
  254. #define PRINTER_EVENT_ADD_CONNECTION 1
  255. #define PRINTER_EVENT_DELETE_CONNECTION 2
  256. #define PRINTER_EVENT_INITIALIZE 3
  257. #define PRINTER_EVENT_DELETE 4
  258. #define PRINTER_EVENT_CACHE_REFRESH 5
  259. #define PRINTER_EVENT_CACHE_DELETE 6
  260. //
  261. // DrvPrinterEvent Flags
  262. //
  263. #define PRINTER_EVENT_FLAG_NO_UI 0x00000001
  264. BOOL
  265. DrvPrinterEvent(
  266. LPWSTR pPrinterName,
  267. int DriverEvent,
  268. DWORD Flags,
  269. LPARAM lParam
  270. );
  271. //
  272. // User Mode Printer Driver DLL,
  273. //
  274. // Note on hPrinter passed into DrvSplStartDoc() and subsequent
  275. // DrvSplxxx calls
  276. //
  277. //
  278. // A. If you have DrvSplxxxx calls in separate DLL and link it with
  279. // spoolss.lib.
  280. //
  281. // * The hPrinter will be valid for any call to the spooler, such as
  282. // WritePrinter(), GetPrinterData()
  283. //
  284. // * To do this you must
  285. //
  286. // 1. Have separate DLL for all DrvSplxxx functions.
  287. // 2. Put this DLL name into your dependency files (inf).
  288. // 3. link to spoolss.lib rather than winspool.lib
  289. // 4. Use SetPrinterData() with SPLPRINTER_USER_MODE_PRINTER_DRIVER
  290. // as key name, and this DLL name as data.
  291. // 5. Call any spooler functions linked from spoolss.lib
  292. //
  293. //
  294. //
  295. // B. If you have DrvSplxxx calls located in your printer driver UI DLL and
  296. // linked with winspool.lib
  297. //
  298. // * The hPrinter is NOT valid for any spooler calls, such as
  299. // WritePrinter(), GetPrinterData() from within the DrvSplxxx driver
  300. // functions.
  301. //
  302. // * To do any spooler call from inside of DrvSplxxxx function you must
  303. // do the following
  304. //
  305. // 1. hSpoolSS = LoadLibrary("spoolss.dll");
  306. // 2. pfn = GetProcAddress("WritePrinter") or whatever the spooler
  307. // functions you wish to call
  308. // 3. Call the pfn function pointer returned from GetProcAddress()
  309. // 4. FreeLibrary(hSpoolSS);
  310. //
  311. //
  312. // The A method is recommended.
  313. //
  314. //
  315. // If a UserModePrinterDriver DLL is created the following routines are
  316. // required or optional
  317. //
  318. // Required Routines
  319. // DrvSplStartDoc
  320. // DrvSplWritePrinter
  321. // DrvSplEndDoc
  322. // DrvSplClose
  323. //
  324. //
  325. // Optional Routines
  326. // DrvSplStart
  327. // DrvSplEndPage
  328. // DrvSplAbort
  329. //
  330. //
  331. HANDLE
  332. DrvSplStartDoc(
  333. HANDLE hPrinter,
  334. DWORD JobId
  335. );
  336. BOOL
  337. DrvSplWritePrinter(
  338. HANDLE hDriver,
  339. LPVOID pBuf,
  340. DWORD cbBuf,
  341. LPDWORD pcWritten
  342. );
  343. VOID
  344. DrvSplEndDoc(
  345. HANDLE hDriver
  346. );
  347. VOID
  348. DrvSplClose(
  349. HANDLE hDriver
  350. );
  351. BOOL
  352. DrvSplStartPage(
  353. HANDLE hDriver
  354. );
  355. BOOL
  356. DrvSplEndPage(
  357. HANDLE hDriver
  358. );
  359. VOID
  360. DrvSplAbort(
  361. HANDLE hDriver
  362. );
  363. //
  364. // Printer Attribute
  365. // Use with SetPrinterData to define UMPD.DLL
  366. //
  367. #define SPLPRINTER_USER_MODE_PRINTER_DRIVER TEXT("SPLUserModePrinterDriver")
  368. #ifdef __cplusplus
  369. }
  370. #endif
  371. #endif /* !_WINDDIUI_ */