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.

634 lines
19 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_DONT_CHANGE_DRIVER = 1 <<12,
  329. PRST_MINIMUM_SETTINGS = PRST_PRINTER_DATA | PRST_PRINTER_INFO_2 | PRST_PRINTER_DEVMODE,
  330. PRST_ALL_SETTINGS = PRST_MINIMUM_SETTINGS |
  331. PRST_PRINTER_INFO_7 |
  332. PRST_PRINTER_SEC |
  333. PRST_USER_DEVMODE |
  334. PRST_COLOR_PROF,
  335. } PrinterPersistentFlags;
  336. /********************************************************************
  337. IPrnStream query flags.
  338. ********************************************************************/
  339. typedef enum _PrinterPersistentQueryFlag
  340. {
  341. kPrinterPersistentPrinterInfo2,
  342. kPrinterPersistentPrinterInfo7,
  343. kPrinterPersistentUserDevMode,
  344. kPrinterPersistentPrinterDevMode,
  345. kPrinterPersistentSecurity,
  346. kPrinterPersistentColorProfile,
  347. } PrinterPersistentQueryFlag;
  348. typedef union _PersistentInfo
  349. {
  350. PRINTER_INFO_2 *pi2;
  351. PRINTER_INFO_7 *pi7;
  352. DEVMODE *pDevMode;
  353. SECURITY_DESCRIPTOR *pszSecurity;
  354. LPWSTR pMultiSzColor;
  355. } PersistentInfo;
  356. /********************************************************************
  357. IPrnStream interface definition
  358. ********************************************************************/
  359. #undef INTERFACE
  360. #define INTERFACE IPrnStream
  361. DECLARE_INTERFACE_(IPrnStream, IUnknown)
  362. {
  363. // *** IUnknown methods ***
  364. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  365. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  366. STDMETHOD_(ULONG,Release) (THIS) PURE;
  367. // IPrnStream methods
  368. STDMETHOD(BindPrinterAndFile)(THIS_ LPCWSTR pszPrinter, LPCWSTR pszFile) PURE;
  369. STDMETHOD(StorePrinterInfo)(THIS_ DWORD dwFlag) PURE;
  370. STDMETHOD(RestorePrinterInfo)(THIS_ DWORD dwFlag) PURE;
  371. STDMETHOD(QueryPrinterInfo)(THIS_ PrinterPersistentQueryFlag Flag, PersistentInfo *pPrstInfo) PURE;
  372. };
  373. /********************************************************************
  374. Error codes returned by IPrnStream methods
  375. ********************************************************************/
  376. typedef enum _PrnPrstError
  377. {
  378. //
  379. // When storing/ restoring opereations called and
  380. // BindPrinterAndFile wasn't called or failed
  381. //
  382. PRN_PERSIST_ERROR_INVALID_OBJ = 0x1,
  383. //
  384. // Failed to write Printer data because writing failure
  385. //
  386. PRN_PERSIST_ERROR_WRITE_PRNDATA = 0x2,
  387. //
  388. // Failed to restore Printer data because SetPrinterData failed
  389. //
  390. PRN_PERSIST_ERROR_RESTORE_PRNDATA = 0x3,
  391. //
  392. // Failed to restore Printer data because because reading failure
  393. //
  394. PRN_PERSIST_ERROR_READ_PRNDATA = 0x4,
  395. //
  396. // Failed to store Printer Info 2 because writing failure
  397. //
  398. PRN_PERSIST_ERROR_WRITE_PI2 = 0x5,
  399. //
  400. // Failed to store Printer Info 2 because GetPrinter failure
  401. //
  402. PRN_PERSIST_ERROR_GET_PI2 = 0x6,
  403. //
  404. // Failed to restore Printer Info 2 because reading failure
  405. //
  406. PRN_PERSIST_ERROR_READ_PI2 = 0x7,
  407. //
  408. // Failed to restore Printer Info 2 because SetPrinter failure
  409. //
  410. PRN_PERSIST_ERROR_RESTORE_PI2 = 0x8,
  411. //
  412. // Failed to store Printer Info 7 because writing failure
  413. //
  414. PRN_PERSIST_ERROR_WRITE_PI7 = 0x9,
  415. //
  416. // Failed to store Printer Info 7 because GetPrinter failure
  417. //
  418. PRN_PERSIST_ERROR_GET_PI7 = 0xa,
  419. //
  420. // Failed to restore Printer Info 7 because reading failure
  421. //
  422. PRN_PERSIST_ERROR_READ_PI7 = 0xb,
  423. //
  424. // Failed to restore Printer Info 7 because SetPrinter failure
  425. //
  426. PRN_PERSIST_ERROR_RESTORE_PI7 = 0xc,
  427. //
  428. // Failed to store Printer Security Descriptor because writing failure
  429. //
  430. PRN_PERSIST_ERROR_WRITE_SEC = 0xd,
  431. //
  432. // Failed to store Printer Security Descriptor because GetPrinter failure
  433. //
  434. PRN_PERSIST_ERROR_GET_SEC = 0xe,
  435. //
  436. // Failed to restore Printer Security Descriptor because reading failure
  437. //
  438. PRN_PERSIST_ERROR_READ_SEC = 0xf,
  439. //
  440. // Failed to restore Printer Security Descriptor because SetPrinter failure
  441. //
  442. PRN_PERSIST_ERROR_RESTORE_SEC = 0x10,
  443. //
  444. // Failed to store Printer Color Profiles because writing failure
  445. //
  446. PRN_PERSIST_ERROR_WRITE_COLOR_PRF = 0x11,
  447. //
  448. // Failed to store Printer Color Profiles because EnumcolorProfiles failure
  449. //
  450. PRN_PERSIST_ERROR_GET_COLOR_PRF = 0x12,
  451. //
  452. // Failed to restore Printer Color Profiles because reading failure
  453. //
  454. PRN_PERSIST_ERROR_READ_COLOR_PRF = 0x13,
  455. //
  456. // Failed to restore Printer Color Profiles because AddColorProfile failure
  457. //
  458. PRN_PERSIST_ERROR_RESTORE_COLOR_PRF = 0x14,
  459. //
  460. // Failed to store User DevMode because writing failure
  461. //
  462. PRN_PERSIST_ERROR_WRITE_USR_DEVMODE = 0x15,
  463. //
  464. // Failed to store User DevMode because GetPrinter failure
  465. //
  466. PRN_PERSIST_ERROR_GET_USR_DEVMODE = 0x16,
  467. //
  468. // Failed to restore User DevMode because reading failure
  469. //
  470. PRN_PERSIST_ERROR_READ_USR_DEVMODE = 0x17,
  471. //
  472. // Failed to restore User DevMode because SetPrinter failure
  473. //
  474. PRN_PERSIST_ERROR_RESTORE_USR_DEVMODE = 0x18,
  475. //
  476. // Failed to store Printer DevMode because writing failure
  477. //
  478. PRN_PERSIST_ERROR_WRITE_PRN_DEVMODE = 0x19,
  479. //
  480. // Failed to store Printer DevMode because GetPrinter failure
  481. //
  482. PRN_PERSIST_ERROR_GET_PRN_DEVMODE = 0x1a,
  483. //
  484. // Failed to restore Printer DevMode because reading failure
  485. //
  486. PRN_PERSIST_ERROR_READ_PRN_DEVMODE = 0x1b,
  487. //
  488. // Failed to restore Printer DevMode because SetPrinter failure
  489. //
  490. PRN_PERSIST_ERROR_RESTORE_PRN_DEVMODE = 0x1c,
  491. //
  492. // Failed because of unresolved printer name conflict
  493. //
  494. PRN_PERSIST_ERROR_PRN_NAME_CONFLICT = 0x1d,
  495. //
  496. // Failed because of printer name conflict
  497. //
  498. PRN_PERSIST_ERROR_UNBOUND = 0x1e,
  499. //
  500. // Restoring failure because failure at building backup info
  501. //
  502. PRN_PERSIST_ERROR_BACKUP = 0x1f,
  503. //
  504. // Restoring failure and Backup Failure too ; printer settings in undefined status
  505. //
  506. PRN_PERSIST_ERROR_FATAL = 0xffff
  507. } PrnPrstError;
  508. /********************************************************************
  509. IID_IPrintUIServices interface definition
  510. ********************************************************************/
  511. #undef INTERFACE
  512. #define INTERFACE IPrintUIServices
  513. DECLARE_INTERFACE_(IPrintUIServices, IUnknown)
  514. {
  515. // *** IUnknown methods ***
  516. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  517. STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  518. STDMETHOD_(ULONG,Release)(THIS) PURE;
  519. // *** IID_IPrintUIServices methods ***
  520. STDMETHOD(GenerateShareName)(THIS_ LPCTSTR lpszServer, LPCTSTR lpszBaseName, LPTSTR lpszOut, int cchMaxChars) PURE;
  521. };
  522. #ifdef __cplusplus
  523. }
  524. #endif
  525. #endif // ndef _PRTLIB_HXX