Source code of Windows XP (NT5)
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.

633 lines
18 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. WinPrtP.h
  6. Abstract:
  7. Private PrintUI library public header.
  8. Author:
  9. Albert Ting (AlbertT) 27-Jun-95
  10. Revision History:
  11. --*/
  12. DEFINE_GUID(CLSID_PrintUIShellExtension, 0x77597368, 0x7b15, 0x11d0, 0xa0, 0xc2, 0x08, 0x00, 0x36, 0xaf, 0x3f, 0x03 );
  13. DEFINE_GUID(IID_IFindPrinter, 0xb4cd8efc, 0xd70b, 0x11d1, 0x99, 0xb1, 0x8, 0x0, 0x36, 0xaf, 0x3f, 0x3);
  14. DEFINE_GUID(IID_IPrinterFolder, 0xef99abd4, 0x5b8d, 0x11d1, 0xa9, 0xc8, 0x8, 0x0, 0x36, 0xaf, 0x3f, 0x3);
  15. DEFINE_GUID(IID_IFolderNotify, 0xff22d71, 0x5172, 0x11d1, 0xa9, 0xc6, 0x8, 0x0, 0x36, 0xaf, 0x3f, 0x3);
  16. DEFINE_GUID(IID_IDsPrinterProperties,0x8a58bc16, 0x410e, 0x11d1, 0xa9, 0xc2, 0x8, 0x0, 0x36, 0xaf, 0x3f, 0x3);
  17. DEFINE_GUID(IID_IPhysicalLocation, 0xdfe8c7eb, 0x651b, 0x11d2, 0x92, 0xce, 0x08, 0x00, 0x36, 0xaf, 0x3f, 0x03);
  18. DEFINE_GUID(IID_IPrnStream, 0xa24c1d62, 0x75f5, 0x11d2, 0xb8, 0x99, 0x0, 0xc0, 0x4f, 0x86, 0xae, 0x55);
  19. // {2E4599E1-BE2C-436a-B0AD-3D0E347F34B3}
  20. DEFINE_GUID(IID_IPrintUIServices, 0x2e4599e1, 0xbe2c, 0x436a, 0xb0, 0xad, 0x3d, 0xe, 0x34, 0x7f, 0x34, 0xb3);
  21. #ifndef _PRTLIB_H
  22. #define _PRTLIB_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /********************************************************************
  27. Prototypes
  28. ********************************************************************/
  29. //
  30. // Initialize the library.
  31. //
  32. BOOL
  33. bPrintLibInit(
  34. VOID
  35. );
  36. //
  37. // Create a new print queue.
  38. //
  39. VOID
  40. vQueueCreate(
  41. HWND hwndOwner,
  42. LPCTSTR pszPrinter,
  43. INT nCmdShow,
  44. LPARAM lParam
  45. );
  46. //
  47. // Display document defaults for a print queue.
  48. //
  49. VOID
  50. vDocumentDefaults(
  51. HWND hwndOwner,
  52. LPCTSTR pszPrinterName,
  53. INT nCmdShow,
  54. LPARAM lParam
  55. );
  56. #define PRINTER_SHARING_PAGE 1
  57. //
  58. // Display properties for a print queue.
  59. //
  60. VOID
  61. vPrinterPropPages(
  62. HWND hwndOwner,
  63. LPCTSTR pszPrinterName,
  64. INT nCmdShow,
  65. LPARAM lParam
  66. );
  67. VOID
  68. vServerPropPages(
  69. HWND hwndOwner,
  70. LPCTSTR pszServerName,
  71. INT nCmdShow,
  72. LPARAM lParam
  73. );
  74. //
  75. // Run printer and drivers setup.
  76. //
  77. BOOL
  78. bPrinterSetup(
  79. HWND hwnd,
  80. UINT uAction,
  81. UINT cchPrinterName,
  82. LPTSTR pszPrinterName,
  83. UINT* pcchPrinterName,
  84. LPCTSTR pszServerName
  85. );
  86. /********************************************************************
  87. Print folder interfaces.
  88. ********************************************************************/
  89. /********************************************************************
  90. Printers Folder Extenstion Interface. This interface extends
  91. the printers IShellFolder implementation.
  92. ********************************************************************/
  93. #undef INTERFACE
  94. #define INTERFACE IPrinterFolder
  95. DECLARE_INTERFACE_(IPrinterFolder, IUnknown)
  96. {
  97. // *** IUnknown methods ***
  98. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  99. STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  100. STDMETHOD_(ULONG,Release)(THIS) PURE;
  101. // *** IPrintersFolder methods ***
  102. STDMETHOD_(BOOL, IsPrinter)( THIS_ LPCITEMIDLIST pidl ) PURE;
  103. };
  104. /********************************************************************
  105. Folder Notification interface.
  106. ********************************************************************/
  107. //
  108. // Folder notify type
  109. //
  110. typedef enum IFolderNotifyType
  111. {
  112. kFolderNone, // No item changed do not generate notification
  113. kFolderUpdate, // Item changed
  114. kFolderAttributes, // Item attribute changed
  115. kFolderCreate, // Item created
  116. kFolderDelete, // Item deleted
  117. kFolderRename, // Item renamed
  118. kFolderUpdateAll, // Update all items == 'F5'
  119. } FOLDER_NOTIFY_TYPE, *PFOLDER_NOTIFY_TYPE;
  120. //
  121. // Folder notification callback interface definition.
  122. //
  123. #undef INTERFACE
  124. #define INTERFACE IFolderNotify
  125. DECLARE_INTERFACE_(IFolderNotify, IUnknown)
  126. {
  127. // *** IUnknown methods ***
  128. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  129. STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  130. STDMETHOD_(ULONG,Release)(THIS) PURE;
  131. // *** IFolderNotify methods ***
  132. STDMETHOD_(BOOL, ProcessNotify)( THIS_ FOLDER_NOTIFY_TYPE NotifyType, LPCWSTR pszName, LPCWSTR pszNewName ) PURE;
  133. };
  134. typedef struct _FOLDER_PRINTER_DATA {
  135. LPCTSTR pName;
  136. LPCTSTR pComment;
  137. DWORD Status;
  138. DWORD Attributes;
  139. DWORD cJobs;
  140. DWORD cbSize;
  141. LPCTSTR pLocation;
  142. LPCTSTR pDriverName;
  143. LPCTSTR pStatus; // Connection status i.e. <opening...>
  144. LPCTSTR pPortName;
  145. } FOLDER_PRINTER_DATA, *PFOLDER_PRINTER_DATA;
  146. //
  147. // Register folder watch. Currently this only works for print
  148. // servers; connections aren't maintained.
  149. //
  150. HRESULT
  151. RegisterPrintNotify(
  152. IN LPCTSTR pszDataSource,
  153. IN IFolderNotify *pClientNotify,
  154. OUT LPHANDLE phFolder,
  155. OUT PBOOL pbAdministrator OPTIONAL
  156. );
  157. //
  158. // Unregister folder watch. Currently this only works for print
  159. // servers; connections aren't maintained.
  160. //
  161. HRESULT
  162. UnregisterPrintNotify(
  163. IN LPCTSTR pszDataSource,
  164. IN IFolderNotify *pClientNotify,
  165. OUT LPHANDLE phFolder
  166. );
  167. BOOL
  168. bFolderEnumPrinters(
  169. IN HANDLE hFolder,
  170. OUT PFOLDER_PRINTER_DATA pData,
  171. IN DWORD cbData,
  172. OUT PDWORD pcbNeeded,
  173. OUT PDWORD pcbReturned
  174. );
  175. BOOL
  176. bFolderRefresh(
  177. IN HANDLE hFolder,
  178. OUT PBOOL pbAdministrator
  179. );
  180. BOOL
  181. bFolderGetPrinter(
  182. IN HANDLE hFolder,
  183. IN LPCTSTR pszPrinter,
  184. OUT PFOLDER_PRINTER_DATA pData,
  185. IN DWORD cbData,
  186. OUT PDWORD pcbNeeded
  187. );
  188. /********************************************************************
  189. PrintUI error support (exposed to shell)
  190. ********************************************************************/
  191. HRESULT
  192. ShowErrorMessageSC(
  193. OUT INT *piResult,
  194. IN HINSTANCE hModule,
  195. IN HWND hwnd,
  196. IN LPCTSTR pszTitle,
  197. IN LPCTSTR pszMessage,
  198. IN UINT uType,
  199. IN DWORD dwCode
  200. );
  201. HRESULT
  202. ShowErrorMessageHR(
  203. OUT INT *piResult,
  204. IN HINSTANCE hModule,
  205. IN HWND hwnd,
  206. IN LPCTSTR pszTitle,
  207. IN LPCTSTR pszMessage,
  208. IN UINT uType,
  209. IN HRESULT hr
  210. );
  211. /********************************************************************
  212. IPhysicalLocation
  213. ********************************************************************/
  214. #undef INTERFACE
  215. #define INTERFACE IPhysicalLocation
  216. DECLARE_INTERFACE_(IPhysicalLocation, IUnknown)
  217. {
  218. // *** IUnknown methods ***
  219. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  220. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  221. STDMETHOD_(ULONG,Release) (THIS) PURE;
  222. // IPhysicalLocation methods
  223. STDMETHOD(DiscoverPhysicalLocation)(THIS) PURE;
  224. STDMETHOD(GetExactPhysicalLocation)(THIS_ BSTR *pbsLocation) PURE;
  225. STDMETHOD(GetSearchPhysicalLocation)(THIS_ BSTR *pbsLocation) PURE;
  226. // IPhysicalLocation methods for fetching individual physical locations
  227. STDMETHOD(GetUserPhysicalLocation)(THIS_ BSTR *pbsLocation) PURE;
  228. STDMETHOD(GetMachinePhysicalLocation)(THIS_ BSTR *pbsLocation) PURE;
  229. STDMETHOD(GetSubnetPhysicalLocation)(THIS_ BSTR *pbsLocation) PURE;
  230. STDMETHOD(GetSitePhysicalLocation)(THIS_ BSTR *pbsLocation) PURE;
  231. STDMETHOD(BrowseForLocation)(THIS_ HWND hParent, BSTR bsDefault, BSTR *pbsLocation) PURE;
  232. STDMETHOD(ShowPhysicalLocationUI)(THIS) PURE;
  233. };
  234. /********************************************************************
  235. IDsPrinterProperties
  236. This is a private interface used to launch printer properties
  237. from the DS MMC snapin.
  238. ********************************************************************/
  239. #undef INTERFACE
  240. #define INTERFACE IDsPrinterProperties
  241. DECLARE_INTERFACE_(IDsPrinterProperties, IUnknown)
  242. {
  243. // *** IUnknown methods ***
  244. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  245. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  246. STDMETHOD_(ULONG,Release) (THIS) PURE;
  247. // IDsFolder methods
  248. STDMETHOD(ShowProperties)(THIS_ HWND hwndParent, LPCWSTR pszObjectPath, PBOOL pbDisplayed) PURE;
  249. };
  250. /********************************************************************
  251. Find Printer Interface. This inferface allows a user to find
  252. a printer either on the network or in the DS if one is
  253. available.
  254. ********************************************************************/
  255. #undef INTERFACE
  256. #define INTERFACE IFindPrinter
  257. DECLARE_INTERFACE_(IFindPrinter, IUnknown)
  258. {
  259. // *** IUnknown methods ***
  260. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  261. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  262. STDMETHOD_(ULONG,Release) (THIS) PURE;
  263. // IFindPrinter methods
  264. STDMETHOD(FindPrinter)(THIS_ HWND hwnd, LPWSTR pszBuffer, UINT *puSize) PURE;
  265. };
  266. /********************************************************************
  267. IPageSwitch - Interface used as a connection point for
  268. the connect to printer dialog when integrated in a wizard.
  269. ********************************************************************/
  270. #undef INTERFACE
  271. #define INTERFACE IPageSwitch
  272. DECLARE_INTERFACE(IPageSwitch)
  273. {
  274. // *** INotifyReflect methods ***
  275. //
  276. // This functions provide opportunity to the client to change
  277. // the next/prev page ID and/or allow/deny advancing to the
  278. // next/prev page.
  279. //
  280. // S_OK: means you can advance to the next/prev page
  281. // S_FALSE: means you cant advance to the next/prev page
  282. //
  283. STDMETHOD(GetPrevPageID)( THIS_ UINT *puPageID ) PURE;
  284. STDMETHOD(GetNextPageID)( THIS_ UINT *puPageID ) PURE;
  285. //
  286. // The property page calls this method when the printer connection is
  287. // successfully created and we are about to advance to the
  288. // next/prev page
  289. //
  290. STDMETHOD(SetPrinterInfo)( THIS_ LPCWSTR pszPrinterName, LPCWSTR pszComment, LPCWSTR pszLocation, LPCWSTR pszShareName ) PURE;
  291. //
  292. // This method provide notification to the client that
  293. // the user clicked "Cancel" button on the wizard - which
  294. // normaly leads to closing the wizard.
  295. //
  296. // S_OK - Prevent cancel operation
  297. // S_FALSE - Allow cancel operation
  298. //
  299. STDMETHOD(QueryCancel)( THIS ) PURE;
  300. };
  301. //
  302. // The API function for creating the ConnectToPrinterDlg style
  303. // property page
  304. //
  305. HRESULT
  306. ConnectToPrinterPropertyPage(
  307. OUT HPROPSHEETPAGE *phPsp,
  308. OUT UINT *puPageID,
  309. IN IPageSwitch *pPageSwitchController
  310. );
  311. /********************************************************************
  312. IPrnStream flags
  313. ********************************************************************/
  314. typedef enum _PrinterPersistentFlags
  315. {
  316. PRST_PRINTER_DATA = 1<<0,
  317. PRST_PRINTER_INFO_2 = 1<<1,
  318. PRST_PRINTER_INFO_7 = 1<<2,
  319. PRST_PRINTER_SEC = 1<<3,
  320. PRST_USER_DEVMODE = 1<<4,
  321. PRST_PRINTER_DEVMODE = 1<<5,
  322. PRST_COLOR_PROF = 1<<6,
  323. PRST_FORCE_NAME = 1<<7,
  324. PRST_RESOLVE_NAME = 1<<8,
  325. PRST_RESOLVE_PORT = 1<<9,
  326. PRST_RESOLVE_SHARE = 1<<10,
  327. PRST_DONT_GENERATE_SHARE = 1<<11,
  328. PRST_MINIMUM_SETTINGS = PRST_PRINTER_DATA | PRST_PRINTER_INFO_2 | PRST_PRINTER_DEVMODE,
  329. PRST_ALL_SETTINGS = PRST_MINIMUM_SETTINGS |
  330. PRST_PRINTER_INFO_7 |
  331. PRST_PRINTER_SEC |
  332. PRST_USER_DEVMODE |
  333. PRST_COLOR_PROF,
  334. } PrinterPersistentFlags;
  335. /********************************************************************
  336. IPrnStream query flags.
  337. ********************************************************************/
  338. typedef enum _PrinterPersistentQueryFlag
  339. {
  340. kPrinterPersistentPrinterInfo2,
  341. kPrinterPersistentPrinterInfo7,
  342. kPrinterPersistentUserDevMode,
  343. kPrinterPersistentPrinterDevMode,
  344. kPrinterPersistentSecurity,
  345. kPrinterPersistentColorProfile,
  346. } PrinterPersistentQueryFlag;
  347. typedef union _PersistentInfo
  348. {
  349. PRINTER_INFO_2 *pi2;
  350. PRINTER_INFO_7 *pi7;
  351. DEVMODE *pDevMode;
  352. SECURITY_DESCRIPTOR *pszSecurity;
  353. LPWSTR pMultiSzColor;
  354. } PersistentInfo;
  355. /********************************************************************
  356. IPrnStream interface definition
  357. ********************************************************************/
  358. #undef INTERFACE
  359. #define INTERFACE IPrnStream
  360. DECLARE_INTERFACE_(IPrnStream, IUnknown)
  361. {
  362. // *** IUnknown methods ***
  363. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  364. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  365. STDMETHOD_(ULONG,Release) (THIS) PURE;
  366. // IPrnStream methods
  367. STDMETHOD(BindPrinterAndFile)(THIS_ LPCWSTR pszPrinter, LPCWSTR pszFile) PURE;
  368. STDMETHOD(StorePrinterInfo)(THIS_ DWORD dwFlag) PURE;
  369. STDMETHOD(RestorePrinterInfo)(THIS_ DWORD dwFlag) PURE;
  370. STDMETHOD(QueryPrinterInfo)(THIS_ PrinterPersistentQueryFlag Flag, PersistentInfo *pPrstInfo) PURE;
  371. };
  372. /********************************************************************
  373. Error codes returned by IPrnStream methods
  374. ********************************************************************/
  375. typedef enum _PrnPrstError
  376. {
  377. //
  378. // When storing/ restoring opereations called and
  379. // BindPrinterAndFile wasn't called or failed
  380. //
  381. PRN_PERSIST_ERROR_INVALID_OBJ = 0x1,
  382. //
  383. // Failed to write Printer data because writing failure
  384. //
  385. PRN_PERSIST_ERROR_WRITE_PRNDATA = 0x2,
  386. //
  387. // Failed to restore Printer data because SetPrinterData failed
  388. //
  389. PRN_PERSIST_ERROR_RESTORE_PRNDATA = 0x3,
  390. //
  391. // Failed to restore Printer data because because reading failure
  392. //
  393. PRN_PERSIST_ERROR_READ_PRNDATA = 0x4,
  394. //
  395. // Failed to store Printer Info 2 because writing failure
  396. //
  397. PRN_PERSIST_ERROR_WRITE_PI2 = 0x5,
  398. //
  399. // Failed to store Printer Info 2 because GetPrinter failure
  400. //
  401. PRN_PERSIST_ERROR_GET_PI2 = 0x6,
  402. //
  403. // Failed to restore Printer Info 2 because reading failure
  404. //
  405. PRN_PERSIST_ERROR_READ_PI2 = 0x7,
  406. //
  407. // Failed to restore Printer Info 2 because SetPrinter failure
  408. //
  409. PRN_PERSIST_ERROR_RESTORE_PI2 = 0x8,
  410. //
  411. // Failed to store Printer Info 7 because writing failure
  412. //
  413. PRN_PERSIST_ERROR_WRITE_PI7 = 0x9,
  414. //
  415. // Failed to store Printer Info 7 because GetPrinter failure
  416. //
  417. PRN_PERSIST_ERROR_GET_PI7 = 0xa,
  418. //
  419. // Failed to restore Printer Info 7 because reading failure
  420. //
  421. PRN_PERSIST_ERROR_READ_PI7 = 0xb,
  422. //
  423. // Failed to restore Printer Info 7 because SetPrinter failure
  424. //
  425. PRN_PERSIST_ERROR_RESTORE_PI7 = 0xc,
  426. //
  427. // Failed to store Printer Security Descriptor because writing failure
  428. //
  429. PRN_PERSIST_ERROR_WRITE_SEC = 0xd,
  430. //
  431. // Failed to store Printer Security Descriptor because GetPrinter failure
  432. //
  433. PRN_PERSIST_ERROR_GET_SEC = 0xe,
  434. //
  435. // Failed to restore Printer Security Descriptor because reading failure
  436. //
  437. PRN_PERSIST_ERROR_READ_SEC = 0xf,
  438. //
  439. // Failed to restore Printer Security Descriptor because SetPrinter failure
  440. //
  441. PRN_PERSIST_ERROR_RESTORE_SEC = 0x10,
  442. //
  443. // Failed to store Printer Color Profiles because writing failure
  444. //
  445. PRN_PERSIST_ERROR_WRITE_COLOR_PRF = 0x11,
  446. //
  447. // Failed to store Printer Color Profiles because EnumcolorProfiles failure
  448. //
  449. PRN_PERSIST_ERROR_GET_COLOR_PRF = 0x12,
  450. //
  451. // Failed to restore Printer Color Profiles because reading failure
  452. //
  453. PRN_PERSIST_ERROR_READ_COLOR_PRF = 0x13,
  454. //
  455. // Failed to restore Printer Color Profiles because AddColorProfile failure
  456. //
  457. PRN_PERSIST_ERROR_RESTORE_COLOR_PRF = 0x14,
  458. //
  459. // Failed to store User DevMode because writing failure
  460. //
  461. PRN_PERSIST_ERROR_WRITE_USR_DEVMODE = 0x15,
  462. //
  463. // Failed to store User DevMode because GetPrinter failure
  464. //
  465. PRN_PERSIST_ERROR_GET_USR_DEVMODE = 0x16,
  466. //
  467. // Failed to restore User DevMode because reading failure
  468. //
  469. PRN_PERSIST_ERROR_READ_USR_DEVMODE = 0x17,
  470. //
  471. // Failed to restore User DevMode because SetPrinter failure
  472. //
  473. PRN_PERSIST_ERROR_RESTORE_USR_DEVMODE = 0x18,
  474. //
  475. // Failed to store Printer DevMode because writing failure
  476. //
  477. PRN_PERSIST_ERROR_WRITE_PRN_DEVMODE = 0x19,
  478. //
  479. // Failed to store Printer DevMode because GetPrinter failure
  480. //
  481. PRN_PERSIST_ERROR_GET_PRN_DEVMODE = 0x1a,
  482. //
  483. // Failed to restore Printer DevMode because reading failure
  484. //
  485. PRN_PERSIST_ERROR_READ_PRN_DEVMODE = 0x1b,
  486. //
  487. // Failed to restore Printer DevMode because SetPrinter failure
  488. //
  489. PRN_PERSIST_ERROR_RESTORE_PRN_DEVMODE = 0x1c,
  490. //
  491. // Failed because of unresolved printer name conflict
  492. //
  493. PRN_PERSIST_ERROR_PRN_NAME_CONFLICT = 0x1d,
  494. //
  495. // Failed because of printer name conflict
  496. //
  497. PRN_PERSIST_ERROR_UNBOUND = 0x1e,
  498. //
  499. // Restoring failure because failure at building backup info
  500. //
  501. PRN_PERSIST_ERROR_BACKUP = 0x1f,
  502. //
  503. // Restoring failure and Backup Failure too ; printer settings in undefined status
  504. //
  505. PRN_PERSIST_ERROR_FATAL = 0xffff
  506. } PrnPrstError;
  507. /********************************************************************
  508. IID_IPrintUIServices interface definition
  509. ********************************************************************/
  510. #undef INTERFACE
  511. #define INTERFACE IPrintUIServices
  512. DECLARE_INTERFACE_(IPrintUIServices, IUnknown)
  513. {
  514. // *** IUnknown methods ***
  515. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  516. STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  517. STDMETHOD_(ULONG,Release)(THIS) PURE;
  518. // *** IID_IPrintUIServices methods ***
  519. STDMETHOD(GenerateShareName)(THIS_ LPCTSTR lpszServer, LPCTSTR lpszBaseName, LPTSTR lpszOut, int cchMaxChars) PURE;
  520. };
  521. #ifdef __cplusplus
  522. }
  523. #endif
  524. #endif // ndef _PRTLIB_HXX