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.

286 lines
6.2 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1995 - 1998
  3. All rights reserved.
  4. Module Name:
  5. printui.hxx
  6. Abstract:
  7. Hold TPrintLib definitions.
  8. Author:
  9. Albert Ting (AlbertT) 27-Jan-1995
  10. Revision History:
  11. --*/
  12. class TPrintLib : public TExec, public MRefCom {
  13. friend TQueue;
  14. SIGNATURE( 'prlb' )
  15. SAFE_NEW
  16. public:
  17. /********************************************************************
  18. TInfo is a worker class used to increment increment the
  19. ref count on gpPrintLib while the request is sent to the
  20. UI thread.
  21. The lives of TInfo and TQueue overlap (and they both acquire
  22. a reference to gpPrintLib) so gpPrintLib's life is maintained.
  23. ********************************************************************/
  24. class TInfo {
  25. SIGNATURE( 'prin' )
  26. ALWAYS_VALID
  27. public:
  28. INT _nCmdShow;
  29. HWND _hwndOwner;
  30. HANDLE _hEventClose;
  31. TCHAR _szPrinter[kPrinterBufMax];
  32. TInfo(
  33. VOID
  34. )
  35. { }
  36. ~TInfo(
  37. VOID
  38. )
  39. { }
  40. TRefLock<TPrintLib> PrintLib;
  41. };
  42. VAR( HWND, hwndQueueCreate );
  43. VAR( TString, strComputerName );
  44. VAR( TRefLock<TNotify>, pNotify );
  45. static
  46. BOOL
  47. bGetSingleton(
  48. TRefLock<TPrintLib> &RefLock
  49. );
  50. BOOL
  51. bValid(
  52. VOID
  53. )
  54. {
  55. return _hwndQueueCreate && VALID_BASE( TExec ) && VALID_BASE( MRefCom );
  56. }
  57. static
  58. LRESULT CALLBACK
  59. lrQueueCreateWndProc(
  60. HWND hwnd,
  61. UINT uMsg,
  62. WPARAM wParam,
  63. LPARAM lParam
  64. );
  65. private:
  66. VAR( HANDLE, hEventInit );
  67. DLINK_BASE( TQueue, Queue, Queue );
  68. VOID
  69. vHandleCreateQueue(
  70. TInfo* pInfo
  71. );
  72. //
  73. // Virtual definition for MRefCom.
  74. //
  75. VOID
  76. vRefZeroed(
  77. VOID
  78. );
  79. HRESULT
  80. hDestroy(
  81. VOID
  82. );
  83. static
  84. DWORD
  85. xMessagePump(
  86. IN TPrintLib *pPrintLib
  87. );
  88. //
  89. // PrintLib is a singleton class; use vNew. vDelete should only
  90. // be called if the object failed to initialize.
  91. //
  92. TPrintLib(
  93. VOID
  94. );
  95. ~TPrintLib(
  96. VOID
  97. );
  98. BOOL
  99. bInitialize(
  100. VOID
  101. );
  102. static TPrintLib *_pPrintLib;
  103. };
  104. /********************************************************************
  105. Keeps track of the number of threads before the library is
  106. released.
  107. ********************************************************************/
  108. namespace TSafeThread {
  109. struct TSafeThreadInfo
  110. {
  111. LPTHREAD_START_ROUTINE lpStartAddress; // pointer to thread function
  112. LPVOID lpParameter; // argument for new thread
  113. HINSTANCE hInstance; // dll instance handle
  114. HANDLE hEventReady; // set when the thread has called LoadLibrary
  115. };
  116. HANDLE
  117. Create(
  118. LPSECURITY_ATTRIBUTES lpThreadAttributes, // pointer to thread security attributes
  119. DWORD dwStackSize, // initial thread stack size, in bytes
  120. LPTHREAD_START_ROUTINE lpStartAddress, // pointer to thread function
  121. LPVOID lpParameter, // argument for new thread
  122. DWORD dwCreationFlags, // creation flags
  123. LPDWORD lpThreadId // pointer to returned thread identifier
  124. );
  125. DWORD WINAPI
  126. Start(
  127. PVOID pVoid // Thread data
  128. );
  129. };
  130. VOID
  131. vWebQueueCreate(
  132. IN HWND hwndOwner,
  133. IN LPCTSTR pszPrinter,
  134. IN INT nCmdShow,
  135. IN LPARAM lParam
  136. );
  137. BOOL
  138. bIsPrinterFaxDevice(
  139. IN LPCTSTR pszPrinter
  140. );
  141. VOID
  142. vFaxQueueCreate(
  143. IN HWND hwndOwner,
  144. IN LPCTSTR pszPrinter,
  145. IN INT nCmdShow,
  146. IN LPARAM lParam
  147. );
  148. VOID
  149. vQueueCreateInternal(
  150. IN HWND hwndOwner,
  151. IN LPCTSTR pszPrinter,
  152. IN INT nCmdShow,
  153. IN LPARAM lParam
  154. );
  155. extern "C"
  156. {
  157. //
  158. // Prototypes of some private APIs exported from winspool.drv
  159. // in Win64 environment.
  160. //
  161. typedef VOID
  162. type_PrintUIQueueCreate(
  163. IN HWND hWnd,
  164. IN LPCWSTR PrinterName,
  165. IN INT CmdShow,
  166. IN LPARAM lParam
  167. );
  168. typedef VOID
  169. type_PrintUIPrinterPropPages(
  170. IN HWND hWnd,
  171. IN LPCWSTR PrinterName,
  172. IN INT CmdShow,
  173. IN LPARAM lParam
  174. );
  175. typedef VOID
  176. type_PrintUIDocumentDefaults(
  177. IN HWND hWnd,
  178. IN LPCWSTR PrinterName,
  179. IN INT CmdShow,
  180. IN LPARAM lParam
  181. );
  182. typedef LONG
  183. type_PrintUIDocumentPropertiesWrap(
  184. HWND hwnd, // handle to parent window
  185. HANDLE hPrinter, // handle to printer object
  186. LPTSTR pDeviceName, // device name
  187. PDEVMODE pDevModeOutput, // modified device mode
  188. PDEVMODE pDevModeInput, // original device mode
  189. DWORD fMode, // mode options
  190. DWORD fExclusionFlags // exclusion flags
  191. );
  192. typedef BOOL
  193. type_PrintUIPrinterSetup(
  194. IN HWND hWnd,
  195. IN UINT uAction,
  196. IN UINT cchPrinterName,
  197. IN OUT LPWSTR pszPrinterName,
  198. OUT UINT *pcchPrinterName,
  199. IN LPCWSTR pszServerName
  200. );
  201. typedef VOID
  202. type_PrintUIServerPropPages(
  203. IN HWND hWnd,
  204. IN LPCWSTR ServerName,
  205. IN INT CmdShow,
  206. IN LPARAM lParam
  207. );
  208. // the function pointers
  209. typedef type_PrintUIQueueCreate* ptr_PrintUIQueueCreate;
  210. typedef type_PrintUIPrinterPropPages* ptr_PrintUIPrinterPropPages;
  211. typedef type_PrintUIDocumentDefaults* ptr_PrintUIDocumentDefaults;
  212. typedef type_PrintUIDocumentPropertiesWrap* ptr_PrintUIDocumentPropertiesWrap;
  213. typedef type_PrintUIPrinterSetup* ptr_PrintUIPrinterSetup;
  214. typedef type_PrintUIServerPropPages* ptr_PrintUIServerPropPages;
  215. // the export ordinals for each function
  216. enum
  217. {
  218. ord_PrintUIQueueCreate = 219,
  219. ord_PrintUIPrinterPropPages = 220,
  220. ord_PrintUIDocumentDefaults = 221,
  221. ord_PrintUIDocumentPropertiesWrap = 229,
  222. ord_PrintUIPrinterSetup = 230,
  223. ord_PrintUIServerPropPages = 231,
  224. };
  225. } // extern "C"