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.

255 lines
4.9 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996
  5. //
  6. // File: cjobop.cxx
  7. //
  8. // Contents:
  9. //
  10. // History: 1-May-96 t-ptam (Patrick Tam) Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "NWCOMPAT.hxx"
  14. #pragma hdrstop
  15. //----------------------------------------------------------------------------
  16. //
  17. // Function: CNWCOMPATPrintJob::Pause
  18. //
  19. // Synopsis:
  20. //
  21. //----------------------------------------------------------------------------
  22. STDMETHODIMP
  23. CNWCOMPATPrintJob::Pause(THIS)
  24. {
  25. BSTR bstrName = NULL;
  26. HANDLE hPrinter = NULL;
  27. HRESULT hr = S_OK;
  28. DWORD dwJobId = 0;
  29. WCHAR szUncPrinterName[MAX_PATH];
  30. hr = NWApiUncFromADsPath(
  31. _pszPrinterPath,
  32. szUncPrinterName
  33. );
  34. BAIL_ON_FAILURE(hr);
  35. //
  36. // Get JobId from name.
  37. //
  38. hr = get_CoreName(&bstrName);
  39. BAIL_ON_FAILURE(hr);
  40. dwJobId = (DWORD)_wtol(bstrName);
  41. //
  42. // Open a handle to the printer with USE access.
  43. //
  44. hr = NWApiOpenPrinter(
  45. szUncPrinterName,
  46. &hPrinter,
  47. PRINTER_ACCESS_USE
  48. );
  49. BAIL_ON_FAILURE(hr);
  50. //
  51. // Pause job.
  52. //
  53. hr = NWApiSetJob(
  54. hPrinter,
  55. dwJobId,
  56. 0,
  57. NULL,
  58. JOB_CONTROL_PAUSE
  59. );
  60. error:
  61. if (hPrinter) {
  62. NWApiClosePrinter(hPrinter);
  63. }
  64. ADSFREESTRING(bstrName);
  65. RRETURN_EXP_IF_ERR(hr);
  66. }
  67. //----------------------------------------------------------------------------
  68. //
  69. // Function: CNWCOMPATPrintJob::Resume
  70. //
  71. // Synopsis:
  72. //
  73. //----------------------------------------------------------------------------
  74. STDMETHODIMP
  75. CNWCOMPATPrintJob::Resume(THIS)
  76. {
  77. BSTR bstrName = NULL;
  78. HANDLE hPrinter = NULL;
  79. HRESULT hr = S_OK;
  80. DWORD dwJobId = 0;
  81. WCHAR szUncPrinterName[MAX_PATH];
  82. hr = NWApiUncFromADsPath(
  83. _pszPrinterPath,
  84. szUncPrinterName
  85. );
  86. BAIL_ON_FAILURE(hr);
  87. //
  88. // Get JobId from name.
  89. //
  90. hr = get_CoreName(&bstrName);
  91. BAIL_ON_FAILURE(hr);
  92. dwJobId = (DWORD)_wtol(bstrName);
  93. //
  94. // Open a handle to the printer with USE access.
  95. //
  96. hr = NWApiOpenPrinter(
  97. szUncPrinterName,
  98. &hPrinter,
  99. PRINTER_ACCESS_USE
  100. );
  101. BAIL_ON_FAILURE(hr);
  102. //
  103. // Resume job.
  104. //
  105. hr = NWApiSetJob(
  106. hPrinter,
  107. dwJobId,
  108. 0,
  109. NULL,
  110. JOB_CONTROL_RESUME
  111. );
  112. error:
  113. if (hPrinter) {
  114. NWApiClosePrinter(hPrinter);
  115. }
  116. ADSFREESTRING(bstrName);
  117. RRETURN_EXP_IF_ERR(hr);
  118. }
  119. //----------------------------------------------------------------------------
  120. //
  121. // Function: CNWCOMPATPrintJob::Remove
  122. //
  123. // Synopsis:
  124. //
  125. //----------------------------------------------------------------------------
  126. STDMETHODIMP
  127. CNWCOMPATPrintJob::Remove(THIS)
  128. {
  129. BSTR bstrName = NULL;
  130. HANDLE hPrinter = NULL;
  131. HRESULT hr = S_OK;
  132. DWORD dwJobId = 0;
  133. WCHAR szUncPrinterName[MAX_PATH];
  134. hr = NWApiUncFromADsPath(
  135. _pszPrinterPath,
  136. szUncPrinterName
  137. );
  138. BAIL_ON_FAILURE(hr);
  139. //
  140. // Get JobId from name.
  141. //
  142. hr = get_CoreName(&bstrName);
  143. BAIL_ON_FAILURE(hr);
  144. dwJobId = (DWORD)_wtol(bstrName);
  145. //
  146. // Open a handle to the printer with USE access.
  147. //
  148. hr = NWApiOpenPrinter(
  149. szUncPrinterName,
  150. &hPrinter,
  151. PRINTER_ACCESS_USE
  152. );
  153. BAIL_ON_FAILURE(hr);
  154. //
  155. // Remove job.
  156. //
  157. hr = NWApiSetJob(
  158. hPrinter,
  159. dwJobId,
  160. 0,
  161. NULL,
  162. JOB_CONTROL_CANCEL
  163. );
  164. error:
  165. if (hPrinter) {
  166. NWApiClosePrinter(hPrinter);
  167. }
  168. ADSFREESTRING(bstrName);
  169. RRETURN_EXP_IF_ERR(hr);
  170. }
  171. //----------------------------------------------------------------------------
  172. //
  173. // Function: CNWCOMPATPrintJob::get_Status
  174. //
  175. // Synopsis:
  176. //
  177. //----------------------------------------------------------------------------
  178. STDMETHODIMP
  179. CNWCOMPATPrintJob::get_Status(
  180. THIS_ LONG FAR* retval
  181. )
  182. {
  183. *retval = _lStatus;
  184. RRETURN(S_OK);
  185. }
  186. //
  187. // Properties Get & Set.
  188. //
  189. STDMETHODIMP
  190. CNWCOMPATPrintJob::put_Position(THIS_ LONG lPosition)
  191. {
  192. PUT_PROPERTY_LONG((IADsPrintJob *)this, Position);
  193. }
  194. STDMETHODIMP
  195. CNWCOMPATPrintJob::get_Position(THIS_ LONG FAR* retval)
  196. {
  197. GET_PROPERTY_LONG((IADsPrintJob *)this, Position);
  198. }
  199. STDMETHODIMP
  200. CNWCOMPATPrintJob::get_PagesPrinted(THIS_ LONG FAR* retval)
  201. {
  202. GET_PROPERTY_LONG((IADsPrintJob *)this, PagesPrinted);
  203. }
  204. STDMETHODIMP
  205. CNWCOMPATPrintJob::get_TimeElapsed(THIS_ LONG FAR* retval)
  206. {
  207. GET_PROPERTY_LONG((IADsPrintJob *)this, TimeElapsed);
  208. }