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.

179 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. All rights reserved
  4. Module Name:
  5. drvsetup.c
  6. Abstract:
  7. This file implements the interface between winspool.drv and ntprint.dll.
  8. Author:
  9. Mark Lawrence (mlawrenc).
  10. Environment:
  11. User Mode -Win32
  12. Revision History:
  13. Larry Zhu (LZhu) Feb 10 -- Added ShowPrintUpgUI
  14. --*/
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. #include "client.h"
  18. #include "drvsetup.h"
  19. /*++
  20. Routine Name:
  21. InitializeSetupInterface
  22. Routine Description:
  23. This routine initializes the setup interfaces. This setup interface could be
  24. expanded over time to support more advance driver options.
  25. Arguments:
  26. pSetupInterface - The setup interface to load and initialize.
  27. Return Value:
  28. Status Return.
  29. --*/
  30. DWORD
  31. InitializeSetupInterface(
  32. IN OUT TSetupInterface *pSetupInterface
  33. )
  34. {
  35. DWORD Status = ERROR_SUCCESS;
  36. pSetupInterface->hLibrary = NULL;
  37. pSetupInterface->pfnSetupShowBlockedDriverUI = NULL;
  38. pSetupInterface->hLibrary = LoadLibrary(L"ntprint.dll");
  39. Status = pSetupInterface->hLibrary != NULL ? ERROR_SUCCESS : GetLastError();
  40. if (Status == ERROR_SUCCESS)
  41. {
  42. pSetupInterface->pfnSetupShowBlockedDriverUI= (pfPSetupShowBlockedDriverUI)
  43. GetProcAddress(pSetupInterface->hLibrary,
  44. "PSetupShowBlockedDriverUI");
  45. Status = pSetupInterface->pfnSetupShowBlockedDriverUI ? ERROR_SUCCESS : ERROR_INVALID_FUNCTION;
  46. }
  47. return Status;
  48. }
  49. /*++
  50. Routine Name:
  51. FreeSetupInterface
  52. Routine Description:
  53. This routine frees the Setup Interface.
  54. Arguments:
  55. pSetupInterface - The setup interface to unload.
  56. Return Value:
  57. Status Return.
  58. --*/
  59. DWORD
  60. FreeSetupInterface(
  61. IN OUT TSetupInterface *pSetupInterface
  62. )
  63. {
  64. DWORD Status = ERROR_SUCCESS;
  65. if (pSetupInterface->hLibrary)
  66. {
  67. Status = FreeLibrary(pSetupInterface->hLibrary) ? ERROR_SUCCESS : GetLastError();
  68. }
  69. return Status;
  70. }
  71. /*++
  72. Routine Name:
  73. ShowPrintUpgUI
  74. Routine Description:
  75. This routine asks ntprint.dll to popup a message box either indicates
  76. the driver is blocked and installation will abort or at the case of
  77. warned driver, whether to preceed the driver installation.
  78. Arguments:
  79. dwBlockingStatus - ErrorCode for blocked or Warned driver
  80. Return Value:
  81. DWORD - If ERROR_SUCCESS, the driver may be installed, otherwise an error
  82. code indicating the failure.
  83. --*/
  84. DWORD
  85. ShowPrintUpgUI(
  86. IN DWORD dwBlockingErrorCode
  87. )
  88. {
  89. DWORD dwStatus = ERROR_SUCCESS;
  90. HWND hWndParent = NULL;
  91. DWORD dwBlockingStatus = BSP_PRINTER_DRIVER_OK;
  92. TSetupInterface SetupInterface;
  93. if (ERROR_PRINTER_DRIVER_BLOCKED == dwBlockingErrorCode)
  94. {
  95. dwBlockingStatus = BSP_PRINTER_DRIVER_BLOCKED;
  96. }
  97. else if (ERROR_PRINTER_DRIVER_WARNED == dwBlockingErrorCode)
  98. {
  99. dwBlockingStatus = BSP_PRINTER_DRIVER_WARNED;
  100. }
  101. else
  102. {
  103. dwStatus = ERROR_INVALID_PARAMETER;
  104. }
  105. if (ERROR_SUCCESS == dwStatus)
  106. {
  107. dwStatus = InitializeSetupInterface(&SetupInterface);
  108. if ((dwStatus == ERROR_SUCCESS))
  109. {
  110. hWndParent = SUCCEEDED(GetCurrentThreadLastPopup(&hWndParent)) ? hWndParent : NULL;
  111. //
  112. // Ask the user what they want to do. If they don't want to proceed,
  113. // then the error is what the would get from the localspl call.
  114. //
  115. dwStatus = (SetupInterface.pfnSetupShowBlockedDriverUI(hWndParent, dwBlockingStatus) & BSP_PRINTER_DRIVER_PROCEEDED) ? ERROR_SUCCESS : dwBlockingErrorCode;
  116. }
  117. (VOID)FreeSetupInterface(&SetupInterface);
  118. }
  119. return dwStatus;
  120. }