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.

243 lines
5.1 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. IID_IADsCollection,
  35. (void **)ppCollection
  36. );
  37. RRETURN_EXP_IF_ERR(hr);
  38. }
  39. //----------------------------------------------------------------------------
  40. //
  41. // Function: CNWCOMPATPrintQueue::Pause
  42. //
  43. // Synopsis:
  44. //
  45. //----------------------------------------------------------------------------
  46. STDMETHODIMP
  47. CNWCOMPATPrintQueue::Pause(THIS)
  48. {
  49. HANDLE hPrinter = NULL;
  50. HRESULT hr = S_OK;
  51. BSTR bstrADsPath = NULL;
  52. WCHAR szUncPrinterName[MAX_PATH];
  53. //
  54. // Make Unc printer name.
  55. //
  56. hr = get_CoreADsPath(&bstrADsPath);
  57. BAIL_ON_FAILURE(hr);
  58. hr = NWApiUncFromADsPath(
  59. bstrADsPath,
  60. szUncPrinterName
  61. );
  62. BAIL_ON_FAILURE(hr);
  63. //
  64. // Open a handle to the printer with Administer access.
  65. //
  66. hr = NWApiOpenPrinter(
  67. szUncPrinterName,
  68. &hPrinter,
  69. PRINTER_ACCESS_ADMINISTER
  70. );
  71. BAIL_ON_FAILURE(hr);
  72. //
  73. // Pause printer.
  74. //
  75. hr = NWApiSetPrinter(
  76. hPrinter,
  77. 0,
  78. NULL,
  79. PRINTER_CONTROL_PAUSE
  80. );
  81. error:
  82. if (hPrinter) {
  83. NWApiClosePrinter(hPrinter);
  84. }
  85. ADSFREESTRING(bstrADsPath);
  86. RRETURN_EXP_IF_ERR(hr);
  87. }
  88. //----------------------------------------------------------------------------
  89. //
  90. // Function: CNWCOMPATPrintQueue::Resume
  91. //
  92. // Synopsis:
  93. //
  94. //----------------------------------------------------------------------------
  95. STDMETHODIMP
  96. CNWCOMPATPrintQueue::Resume(THIS)
  97. {
  98. HANDLE hPrinter = NULL;
  99. HRESULT hr = S_OK;
  100. BSTR bstrADsPath = NULL;
  101. WCHAR szUncPrinterName[MAX_PATH];
  102. //
  103. // Make Unc printer name.
  104. //
  105. hr = get_CoreADsPath(&bstrADsPath);
  106. BAIL_ON_FAILURE(hr);
  107. hr = NWApiUncFromADsPath(
  108. bstrADsPath,
  109. szUncPrinterName
  110. );
  111. BAIL_ON_FAILURE(hr);
  112. //
  113. // Open a handle to the printer with Administer access.
  114. //
  115. hr = NWApiOpenPrinter(
  116. szUncPrinterName,
  117. &hPrinter,
  118. PRINTER_ACCESS_ADMINISTER
  119. );
  120. BAIL_ON_FAILURE(hr);
  121. //
  122. // Resume printer.
  123. //
  124. hr = NWApiSetPrinter(
  125. hPrinter,
  126. 0,
  127. NULL,
  128. PRINTER_CONTROL_RESUME
  129. );
  130. error:
  131. if (hPrinter) {
  132. NWApiClosePrinter(hPrinter);
  133. }
  134. if (bstrADsPath) {
  135. ADsFreeString(bstrADsPath);
  136. }
  137. RRETURN_EXP_IF_ERR(hr);
  138. }
  139. //----------------------------------------------------------------------------
  140. //
  141. // Function: CNWCOMPATPrintQueue::Purge
  142. //
  143. // Synopsis:
  144. //
  145. //----------------------------------------------------------------------------
  146. STDMETHODIMP
  147. CNWCOMPATPrintQueue::Purge(THIS)
  148. {
  149. HANDLE hPrinter = NULL;
  150. HRESULT hr = S_OK;
  151. BSTR bstrADsPath = NULL;
  152. WCHAR szUncPrinterName[MAX_PATH];
  153. //
  154. // Make Unc printer name.
  155. //
  156. hr = get_CoreADsPath(&bstrADsPath);
  157. BAIL_ON_FAILURE(hr);
  158. hr = NWApiUncFromADsPath(
  159. bstrADsPath,
  160. szUncPrinterName
  161. );
  162. BAIL_ON_FAILURE(hr);
  163. //
  164. // Open a handle to the printer with Administer access.
  165. //
  166. hr = NWApiOpenPrinter(
  167. szUncPrinterName,
  168. &hPrinter,
  169. PRINTER_ACCESS_ADMINISTER
  170. );
  171. BAIL_ON_FAILURE(hr);
  172. //
  173. // Purge printer.
  174. //
  175. hr = NWApiSetPrinter(
  176. hPrinter,
  177. 0,
  178. NULL,
  179. PRINTER_CONTROL_PURGE
  180. );
  181. error:
  182. if (hPrinter) {
  183. NWApiClosePrinter(hPrinter);
  184. }
  185. if (bstrADsPath) {
  186. ADsFreeString(bstrADsPath);
  187. }
  188. RRETURN_EXP_IF_ERR(hr);
  189. }
  190. //----------------------------------------------------------------------------
  191. //
  192. // Function: CNWCOMPATPrintQueue::get_Status
  193. //
  194. // Synopsis:
  195. //
  196. //----------------------------------------------------------------------------
  197. STDMETHODIMP
  198. CNWCOMPATPrintQueue::get_Status(
  199. THIS_ long FAR* retval
  200. )
  201. {
  202. GET_PROPERTY_LONG((IADsPrintQueue *)this, Status);
  203. }