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.

221 lines
5.4 KiB

  1. #include "stdafx.h"
  2. #include "WizardSheet.h"
  3. #include "UIUtils.h"
  4. CPackageInfo::CPackageInfo( CWizardSheet* pTheSheet ) :
  5. m_pTheSheet( pTheSheet )
  6. {
  7. m_strTitle.LoadString( IDS_TITLE_PKGINFO );
  8. m_strSubTitle.LoadString( IDS_SUBTITLE_PKGINFO );
  9. SetHeaderTitle( m_strTitle );
  10. SetHeaderSubTitle( m_strSubTitle );
  11. }
  12. BOOL CPackageInfo::OnSetActive()
  13. {
  14. CString strError;
  15. IImportPackagePtr spImport;
  16. ISiteInfoPtr spSite;
  17. CComBSTR bstrData;
  18. CString strEntry;
  19. strEntry.Format( IDS_PKGINFO_PKGNAME, m_pTheSheet->m_pageLoadPkg.m_strFilename );
  20. ListBox_InsertString( GetDlgItem( IDC_INFO ), -1, strEntry );
  21. HRESULT hr = spImport.CreateInstance( CLSID_ImportPackage );
  22. if ( FAILED( hr ) )
  23. {
  24. strError.LoadString( IDS_E_NOENGINE );
  25. }
  26. if ( SUCCEEDED( hr ) )
  27. {
  28. CComBSTR bstrPkg( m_pTheSheet->m_pageLoadPkg.m_strFilename );
  29. CComBSTR bstrPwd( m_pTheSheet->m_pageLoadPkg.m_strPassword );
  30. if ( ( NULL == bstrPkg.m_str ) || ( NULL == bstrPwd.m_str ) )
  31. {
  32. strError = L"Out of memory!";
  33. }
  34. hr = spImport->LoadPackage( bstrPkg, bstrPwd );
  35. }
  36. if ( SUCCEEDED( hr ) )
  37. {
  38. SetDate( spImport );
  39. SetMachine( spImport );
  40. SetOS( spImport );
  41. SetSiteName( spImport );
  42. SetComment( spImport );
  43. }
  44. if ( FAILED( hr ) )
  45. {
  46. UIUtils::ShowCOMError( m_hWnd, IDS_E_LOAD_PKG, IDS_APPTITLE, hr );
  47. SetWizardButtons( PSWIZB_BACK );
  48. }
  49. // Allow the page to be displayd, becasue otherwise the sheet will display the next page
  50. return TRUE;
  51. }
  52. void CPackageInfo::SetDate( const IImportPackagePtr& spImport )
  53. {
  54. DATE dtCreated = 0.0;
  55. _variant_t vntDateStr;
  56. CString strEntry;
  57. CString strData;
  58. strData.LoadString( IDS_PKGINFO_ERROR );
  59. HRESULT hr = spImport->get_TimeCreated( &dtCreated );
  60. if ( SUCCEEDED( hr ) )
  61. {
  62. _variant_t vntDate( dtCreated );
  63. V_VT( &vntDate ) = VT_DATE;
  64. hr = ::VariantChangeType( &vntDateStr, &vntDate, 0, VT_BSTR );
  65. if ( SUCCEEDED( hr ) )
  66. {
  67. strData = V_BSTR( &vntDateStr );
  68. }
  69. }
  70. strEntry.Format( IDS_PKGINFO_PKGDATE, static_cast<LPCWSTR>( strData ) );
  71. ListBox_InsertString( GetDlgItem( IDC_INFO ), -1, strEntry );
  72. }
  73. void CPackageInfo::SetMachine( const IImportPackagePtr& spImport )
  74. {
  75. CString strEntry;
  76. CComBSTR bstrData;
  77. CString strData;
  78. strData.LoadString( IDS_PKGINFO_ERROR );
  79. HRESULT hr = spImport->get_SourceMachine( &bstrData );
  80. if ( SUCCEEDED( hr ) )
  81. {
  82. strData = bstrData;
  83. }
  84. strEntry.Format( IDS_PKGINFO_MACHINE, static_cast<LPCWSTR>( strData ) );
  85. ListBox_InsertString( GetDlgItem( IDC_INFO ), -1, strEntry );
  86. }
  87. void CPackageInfo::SetOS( const IImportPackagePtr& spImport )
  88. {
  89. BYTE btMajor = 0;
  90. BYTE btMinor = 0;
  91. VARIANT_BOOL vbIsServer = VARIANT_FALSE;
  92. CString strEntry, strData;
  93. strData.LoadString( IDS_PKGINFO_ERROR );
  94. HRESULT hr = spImport->GetSourceOSVer( &btMajor, &btMinor, &vbIsServer );
  95. if ( SUCCEEDED( hr ) )
  96. {
  97. WCHAR wszBuffer[ 1024 ] = L"Microsoft Windows ";
  98. switch ( btMajor )
  99. {
  100. case 4:
  101. ::wcscat( wszBuffer, L"NT 4.0" );
  102. if ( vbIsServer != VARIANT_FALSE )
  103. {
  104. ::wcscat( wszBuffer, L" Server" );
  105. }
  106. break;
  107. case 5:
  108. switch( btMinor )
  109. {
  110. case 0:
  111. ::wcscat( wszBuffer, L"2000" );
  112. if ( vbIsServer != VARIANT_FALSE )
  113. {
  114. ::wcscat( wszBuffer, L" Server" );
  115. }
  116. break;
  117. case 1:
  118. ::wcscat( wszBuffer, L"XP" );
  119. break;
  120. case 2:
  121. ::wcscat( wszBuffer, L"Server 2003" );
  122. break;
  123. };
  124. break;
  125. }
  126. strData = wszBuffer;
  127. }
  128. strEntry.Format( IDS_PKGINFO_OS, static_cast<LPCWSTR>( strData ) );
  129. ListBox_InsertString( GetDlgItem( IDC_INFO ), -1, strEntry );
  130. }
  131. void CPackageInfo::SetSiteName( const IImportPackagePtr& spImport )
  132. {
  133. CComBSTR bstr;
  134. ISiteInfoPtr spInfo;
  135. CString strData, strEntry;
  136. strData.LoadString( IDS_PKGINFO_ERROR );
  137. HRESULT hr = spImport->GetSiteInfo( 0, &spInfo );
  138. if ( SUCCEEDED( hr ) )
  139. {
  140. hr = spInfo->get_DisplayName( &bstr );
  141. }
  142. if ( SUCCEEDED( hr ) )
  143. {
  144. strData = bstr;
  145. }
  146. strEntry.Format( IDS_PKGINFO_COMMENT, static_cast<LPCWSTR>( strData ) );
  147. ListBox_InsertString( GetDlgItem( IDC_INFO ), -1, strEntry );
  148. }
  149. void CPackageInfo::SetComment( const IImportPackagePtr& spImport )
  150. {
  151. CComBSTR bstr;
  152. CString strData, strEntry;
  153. strData.LoadString( IDS_PKGINFO_ERROR );
  154. HRESULT hr = spImport->get_Comment( &bstr );
  155. if ( SUCCEEDED( hr ) )
  156. {
  157. strData = bstr;
  158. }
  159. strEntry.Format( IDS_PKGINFO_COMMENT, static_cast<LPCWSTR>( strData ) );
  160. ListBox_InsertString( GetDlgItem( IDC_INFO ), -1, strEntry );
  161. }