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.

244 lines
4.9 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996
  5. //
  6. // File: cpop.cxx
  7. //
  8. // Contents:
  9. //
  10. // History: 30-Apr-96 t-ptam (Patrick Tam) Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "NWCOMPAT.hxx"
  14. #pragma hdrstop
  15. //----------------------------------------------------------------------------
  16. //
  17. // Function: CNWCOMPATPrintQueue::PrintJobs
  18. //
  19. // Synopsis:
  20. //
  21. //----------------------------------------------------------------------------
  22. STDMETHODIMP
  23. CNWCOMPATPrintQueue::PrintJobs(
  24. THIS_ IADsCollection FAR* FAR* ppCollection
  25. )
  26. {
  27. HRESULT hr = S_OK;
  28. //
  29. // Get Job collection object.
  30. //
  31. hr = CNWCOMPATJobCollection::CreateJobCollection(
  32. _Parent,
  33. _Name,
  34. _Credentials,
  35. IID_IADsCollection,
  36. (void **)ppCollection
  37. );
  38. NW_RRETURN_EXP_IF_ERR(hr);
  39. }
  40. //----------------------------------------------------------------------------
  41. //
  42. // Function: CNWCOMPATPrintQueue::Pause
  43. //
  44. // Synopsis:
  45. //
  46. //----------------------------------------------------------------------------
  47. STDMETHODIMP
  48. CNWCOMPATPrintQueue::Pause(THIS)
  49. {
  50. HANDLE hPrinter = NULL;
  51. HRESULT hr = S_OK;
  52. BSTR bstrADsPath = NULL;
  53. WCHAR szUncPrinterName[MAX_PATH];
  54. //
  55. // Make Unc printer name.
  56. //
  57. hr = get_CoreADsPath(&bstrADsPath);
  58. BAIL_ON_FAILURE(hr);
  59. hr = NWApiUncFromADsPath(
  60. bstrADsPath,
  61. szUncPrinterName
  62. );
  63. BAIL_ON_FAILURE(hr);
  64. //
  65. // Open a handle to the printer with Administer access.
  66. //
  67. hr = NWApiOpenPrinter(
  68. szUncPrinterName,
  69. &hPrinter,
  70. PRINTER_ACCESS_ADMINISTER
  71. );
  72. BAIL_ON_FAILURE(hr);
  73. //
  74. // Pause printer.
  75. //
  76. hr = NWApiSetPrinter(
  77. hPrinter,
  78. 0,
  79. NULL,
  80. PRINTER_CONTROL_PAUSE
  81. );
  82. error:
  83. if (hPrinter) {
  84. NWApiClosePrinter(hPrinter);
  85. }
  86. ADSFREESTRING(bstrADsPath);
  87. NW_RRETURN_EXP_IF_ERR(hr);
  88. }
  89. //----------------------------------------------------------------------------
  90. //
  91. // Function: CNWCOMPATPrintQueue::Resume
  92. //
  93. // Synopsis:
  94. //
  95. //----------------------------------------------------------------------------
  96. STDMETHODIMP
  97. CNWCOMPATPrintQueue::Resume(THIS)
  98. {
  99. HANDLE hPrinter = NULL;
  100. HRESULT hr = S_OK;
  101. BSTR bstrADsPath = NULL;
  102. WCHAR szUncPrinterName[MAX_PATH];
  103. //
  104. // Make Unc printer name.
  105. //
  106. hr = get_CoreADsPath(&bstrADsPath);
  107. BAIL_ON_FAILURE(hr);
  108. hr = NWApiUncFromADsPath(
  109. bstrADsPath,
  110. szUncPrinterName
  111. );
  112. BAIL_ON_FAILURE(hr);
  113. //
  114. // Open a handle to the printer with Administer access.
  115. //
  116. hr = NWApiOpenPrinter(
  117. szUncPrinterName,
  118. &hPrinter,
  119. PRINTER_ACCESS_ADMINISTER
  120. );
  121. BAIL_ON_FAILURE(hr);
  122. //
  123. // Resume printer.
  124. //
  125. hr = NWApiSetPrinter(
  126. hPrinter,
  127. 0,
  128. NULL,
  129. PRINTER_CONTROL_RESUME
  130. );
  131. error:
  132. if (hPrinter) {
  133. NWApiClosePrinter(hPrinter);
  134. }
  135. if (bstrADsPath) {
  136. ADsFreeString(bstrADsPath);
  137. }
  138. NW_RRETURN_EXP_IF_ERR(hr);
  139. }
  140. //----------------------------------------------------------------------------
  141. //
  142. // Function: CNWCOMPATPrintQueue::Purge
  143. //
  144. // Synopsis:
  145. //
  146. //----------------------------------------------------------------------------
  147. STDMETHODIMP
  148. CNWCOMPATPrintQueue::Purge(THIS)
  149. {
  150. HANDLE hPrinter = NULL;
  151. HRESULT hr = S_OK;
  152. BSTR bstrADsPath = NULL;
  153. WCHAR szUncPrinterName[MAX_PATH];
  154. //
  155. // Make Unc printer name.
  156. //
  157. hr = get_CoreADsPath(&bstrADsPath);
  158. BAIL_ON_FAILURE(hr);
  159. hr = NWApiUncFromADsPath(
  160. bstrADsPath,
  161. szUncPrinterName
  162. );
  163. BAIL_ON_FAILURE(hr);
  164. //
  165. // Open a handle to the printer with Administer access.
  166. //
  167. hr = NWApiOpenPrinter(
  168. szUncPrinterName,
  169. &hPrinter,
  170. PRINTER_ACCESS_ADMINISTER
  171. );
  172. BAIL_ON_FAILURE(hr);
  173. //
  174. // Purge printer.
  175. //
  176. hr = NWApiSetPrinter(
  177. hPrinter,
  178. 0,
  179. NULL,
  180. PRINTER_CONTROL_PURGE
  181. );
  182. error:
  183. if (hPrinter) {
  184. NWApiClosePrinter(hPrinter);
  185. }
  186. if (bstrADsPath) {
  187. ADsFreeString(bstrADsPath);
  188. }
  189. NW_RRETURN_EXP_IF_ERR(hr);
  190. }
  191. //----------------------------------------------------------------------------
  192. //
  193. // Function: CNWCOMPATPrintQueue::get_Status
  194. //
  195. // Synopsis:
  196. //
  197. //----------------------------------------------------------------------------
  198. STDMETHODIMP
  199. CNWCOMPATPrintQueue::get_Status(
  200. THIS_ long FAR* retval
  201. )
  202. {
  203. GET_PROPERTY_LONG((IADsPrintQueue *)this, Status);
  204. }