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.

181 lines
4.5 KiB

  1. /******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2000
  4. *
  5. * TITLE: Final.cpp
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: KeisukeT
  10. *
  11. * DATE: 27 Mar, 2000
  12. *
  13. * DESCRIPTION:
  14. * Final page of WIA class installer.
  15. *
  16. *
  17. *******************************************************************************/
  18. //
  19. // Precompiled header
  20. //
  21. #include "precomp.h"
  22. #pragma hdrstop
  23. //
  24. // Include
  25. //
  26. #include "finalpg.h"
  27. //
  28. // Function
  29. //
  30. CInstallPage::CInstallPage(PINSTALLER_CONTEXT pInstallerContext) :
  31. CInstallWizardPage(pInstallerContext, EmeraldCity)
  32. {
  33. //
  34. // Set link to previous/next page. This page should show up.
  35. //
  36. m_uPreviousPage = NameTheDevice;
  37. m_uNextPage = 0;
  38. //
  39. // Initialize member.
  40. //
  41. m_pInstallerContext = pInstallerContext;
  42. } // CInstallPage::CInstallPage()
  43. BOOL
  44. CInstallPage::OnInit()
  45. {
  46. HFONT hFont;
  47. //
  48. // Set font of title.
  49. //
  50. hFont = GetIntroFont(m_hwndWizard);
  51. if( hFont ){
  52. HWND hwndControl = GetDlgItem(m_hwnd, CompleteMessage);
  53. if( hwndControl ){
  54. SetWindowFont(hwndControl, hFont, TRUE);
  55. } // if( hwndControl )
  56. } // if( hFont )
  57. return TRUE;
  58. }
  59. BOOL
  60. CInstallPage::OnNotify(
  61. LPNMHDR lpnmh
  62. )
  63. {
  64. if (lpnmh->code == PSN_WIZFINISH){
  65. BOOL bSucceeded;
  66. if(NULL == m_pCDevice){
  67. goto OnNotify_return;
  68. }
  69. //
  70. // Register the device element.
  71. //
  72. bSucceeded = SetupDiRegisterDeviceInfo(m_pCDevice->m_hDevInfo,
  73. m_pCDevice->m_pspDevInfoData,
  74. 0,
  75. NULL,
  76. NULL,
  77. NULL);
  78. if(FALSE == bSucceeded){
  79. DebugTrace(TRACE_ERROR,(("CInstallPage::OnNotify: ERROR!! SetupDiRegisterDeviceInfo() failed. Err=0x%x.\r\n"), GetLastError()));
  80. goto OnNotify_return;
  81. } // if(FALSE == bSucceeded)
  82. //
  83. // Do device installation.
  84. //
  85. {
  86. INSTALLSELECTEDDRIVER pfnInstallSelectedDriver;
  87. HMODULE hNewDevDll;
  88. DWORD dwReboot;
  89. //
  90. // Device/Driver must be selected at this point.
  91. //
  92. //
  93. // Load newdev.dll
  94. //
  95. hNewDevDll = LoadLibrary(NEWDEVDLL);
  96. if(NULL != hNewDevDll){
  97. pfnInstallSelectedDriver = (INSTALLSELECTEDDRIVER)GetProcAddress(hNewDevDll, "InstallSelectedDriver");
  98. if(NULL != pfnInstallSelectedDriver){
  99. //
  100. // Call install function in newdev.dll
  101. //
  102. dwReboot = 0;
  103. bSucceeded = pfnInstallSelectedDriver(NULL, m_pCDevice->m_hDevInfo, NULL, TRUE, NULL);
  104. } else { // if(NULL != pfnInstallSelectedDriver)
  105. DebugTrace(TRACE_ERROR,(("CInstallPage::OnNotify: ERROR!! Unable to get the address of InstallSelectedDriver. Err=0x%x.\r\n"), GetLastError()));
  106. FreeLibrary(hNewDevDll);
  107. goto OnNotify_return;
  108. } // if(NULL == pfnInstallSelectedDriver)
  109. FreeLibrary(hNewDevDll);
  110. } else {
  111. DebugTrace(TRACE_ERROR,(("CInstallPage::OnNotify: ERROR!! Unable to load newdev.dll. Err=0x%x.\r\n"), GetLastError()));
  112. goto OnNotify_return;
  113. } // if(NULL == hNewDevDll)
  114. }
  115. //
  116. // Do post-installation if succeeded, to make sure about the portname and FriendlyName.
  117. //
  118. if(bSucceeded){
  119. m_pCDevice->PostInstall(TRUE);
  120. }
  121. //
  122. // Free device object anyway.
  123. //
  124. delete m_pCDevice;
  125. m_pCDevice = NULL;
  126. m_pInstallerContext->pDevice = NULL;
  127. } // if (lpnmh->code == PSN_WIZFINISH)
  128. if (lpnmh->code == PSN_SETACTIVE){
  129. //
  130. // Get CDevice object from context.
  131. //
  132. m_pCDevice = (CDevice *)m_pInstallerContext->pDevice;
  133. } // if (lpnmh->code == PSN_SETACTIVE)
  134. OnNotify_return:
  135. return FALSE;
  136. }