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.

125 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1990-2003 Microsoft Corporation
  3. Module Name:
  4. drvinfo.c
  5. Abstract:
  6. This module This module contains functions to access spooler's
  7. DRIVER_INFO_1/DRIVER_INFO_2 data strcture
  8. Author:
  9. 02-Dec-1993 Thu 22:54:51 created
  10. [Environment:]
  11. GDI Device Driver - Plotter.
  12. [Notes:]
  13. Revision History:
  14. --*/
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. #define DBG_PLOTFILENAME DbgMiscUtil
  18. #define DBG_DRVINFO2 0x00000001
  19. DEFINE_DBGVAR(0);
  20. #ifdef UMODE
  21. LPBYTE
  22. GetDriverInfo(
  23. HANDLE hPrinter,
  24. UINT DrvInfoLevel
  25. )
  26. /*++
  27. Routine Description:
  28. This function get the DRIVER_INFO_1 Pointer from a hPrinter
  29. Arguments:
  30. hPrinter - The handle to the printer interested
  31. DrvInfoLevel - if 1 then DRIVER_INFO_1 is returned else if 2 then
  32. DRIVER_INFO_2 is returned, any other vaules are invlaid
  33. Return Value:
  34. the return value is NULL if failed else a pointer to the DRIVER_INFO_1 or
  35. DRIVER_INFO_2 is returned, the caller must call LocalFree() to free the
  36. memory object after using it.
  37. Author:
  38. 02-Dec-1993 Thu 22:07:14 created
  39. Revision History:
  40. --*/
  41. {
  42. LPVOID pb;
  43. DWORD cb;
  44. //
  45. // Find out total bytes required
  46. //
  47. PLOTASSERT(1, "GetDriverInfo: Invalid DrvInfoLevl = %u",
  48. (DrvInfoLevel == 1) || (DrvInfoLevel == 2), DrvInfoLevel);
  49. GetPrinterDriver(hPrinter, NULL, DrvInfoLevel, NULL, 0, &cb);
  50. if (xGetLastError() != ERROR_INSUFFICIENT_BUFFER) {
  51. PLOTERR(("GetDriverInfo%d: GetPrinterDriver(1st) error=%08lx",
  52. DrvInfoLevel, xGetLastError()));
  53. } else if (!(pb = (LPBYTE)LocalAlloc(LMEM_FIXED, cb))) {
  54. PLOTERR(("GetDriverInfo%d: LocalAlloc(%ld) failed", DrvInfoLevel, cb));
  55. } else if (GetPrinterDriver(hPrinter, NULL, DrvInfoLevel, pb, cb, &cb)) {
  56. //
  57. // Got it allright, so return it
  58. //
  59. return(pb);
  60. } else {
  61. PLOTERR(("GetDriverInfo%d: GetPrinterDriver(2nd) error=%08lx",
  62. DrvInfoLevel, xGetLastError()));
  63. LocalFree((HLOCAL)pb);
  64. }
  65. return(NULL);
  66. }
  67. #endif