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.

76 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. printers.c
  5. Abstract:
  6. This file implements printer functions for fax.
  7. Author:
  8. Steven Kehrli (steveke) 18-Aug-1999
  9. Environment:
  10. User Mode
  11. --*/
  12. #include <windows.h>
  13. #include <winspool.h>
  14. #include <tchar.h>
  15. #include "faxutil.h"
  16. PVOID
  17. MyEnumPrinters(
  18. LPTSTR pServerName,
  19. DWORD level,
  20. PDWORD pcPrinters,
  21. DWORD dwFlags
  22. )
  23. /*++
  24. Routine Description:
  25. Wrapper function for spooler API EnumPrinters
  26. Arguments:
  27. pServerName - Specifies the name of the print server
  28. level - Level of PRINTER_INFO_x structure
  29. pcPrinters - Returns the number of printers enumerated
  30. dwFlags - Flag bits passed to EnumPrinters
  31. Return Value:
  32. Pointer to an array of PRINTER_INFO_x structures
  33. NULL if there is an error
  34. --*/
  35. {
  36. PBYTE pPrinterInfo = NULL;
  37. DWORD cb;
  38. if (! EnumPrinters(dwFlags, pServerName, level, NULL, 0, &cb, pcPrinters) &&
  39. GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
  40. (pPrinterInfo = MemAlloc(cb)) &&
  41. EnumPrinters(dwFlags, pServerName, level, pPrinterInfo, cb, &cb, pcPrinters))
  42. {
  43. return pPrinterInfo;
  44. }
  45. DebugPrint(( TEXT("EnumPrinters failed: %d\n"), GetLastError()));
  46. MemFree(pPrinterInfo);
  47. return NULL;
  48. }