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.

139 lines
3.1 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: MediaInstallationUnit.cpp
  4. //
  5. // Synopsis: Defines a MediaInstallationUnit
  6. // This object has the knowledge for installing the
  7. // Streaming media service
  8. //
  9. // History: 02/06/2001 JeffJon Created
  10. #include "pch.h"
  11. #include "resource.h"
  12. #include "MediaInstallationUnit.h"
  13. // Finish page help
  14. static PCWSTR CYS_MEDIA_FINISH_PAGE_HELP = L"cys.chm::/cys_configuring_streaming_media_server.htm";
  15. MediaInstallationUnit::MediaInstallationUnit() :
  16. InstallationUnit(
  17. IDS_MEDIA_SERVER_TYPE,
  18. IDS_MEDIA_SERVER_DESCRIPTION,
  19. CYS_MEDIA_FINISH_PAGE_HELP,
  20. MEDIASERVER_INSTALL)
  21. {
  22. LOG_CTOR(MediaInstallationUnit);
  23. }
  24. MediaInstallationUnit::~MediaInstallationUnit()
  25. {
  26. LOG_DTOR(MediaInstallationUnit);
  27. }
  28. InstallationReturnType
  29. MediaInstallationUnit::InstallService(HANDLE logfileHandle, HWND /*hwnd*/)
  30. {
  31. LOG_FUNCTION(MediaInstallationUnit::InstallService);
  32. // Log heading
  33. CYS_APPEND_LOG(String::load(IDS_LOG_MEDIA_HEADING));
  34. String unattendFileText;
  35. String infFileText;
  36. unattendFileText += L"[Components]\n";
  37. unattendFileText += L"WMS=ON\n";
  38. unattendFileText += L"WMS_admin_mmc=ON\n";
  39. unattendFileText += L"WMS_Admin_asp=ON\n";
  40. unattendFileText += L"WMS_SERVER=ON\n";
  41. InstallationReturnType result = INSTALL_SUCCESS;
  42. bool ocmResult = InstallServiceWithOcManager(infFileText, unattendFileText);
  43. if (ocmResult &&
  44. IsServiceInstalled())
  45. {
  46. LOG(L"WMS was installed successfully");
  47. CYS_APPEND_LOG(String::load(IDS_LOG_INSTALL_WMS_SUCCESS));
  48. }
  49. else
  50. {
  51. LOG(L"WMS was failed to install");
  52. CYS_APPEND_LOG(String::load(IDS_LOG_INSTALL_WMS_FAILED));
  53. result = INSTALL_FAILURE;
  54. }
  55. LOG_INSTALL_RETURN(result);
  56. return result;
  57. }
  58. bool
  59. MediaInstallationUnit::IsServiceInstalled()
  60. {
  61. LOG_FUNCTION(MediaInstallationUnit::IsServiceInstalled);
  62. bool result = false;
  63. // If we can find wmsserver.dll, we assume netshow is installed
  64. String wmsServerPath = Win::GetSystemDirectory() + L"\\Windows Media\\Server\\WMSServer.dll";
  65. LOG(String::format(
  66. L"Path to WMS server: %1",
  67. wmsServerPath.c_str()));
  68. if (!wmsServerPath.empty())
  69. {
  70. if (FS::FileExists(wmsServerPath))
  71. {
  72. result = true;
  73. }
  74. else
  75. {
  76. LOG(L"Path does not exist");
  77. }
  78. }
  79. else
  80. {
  81. LOG(L"Failed to append path");
  82. }
  83. LOG_BOOL(result);
  84. return result;
  85. }
  86. bool
  87. MediaInstallationUnit::GetFinishText(String& message)
  88. {
  89. LOG_FUNCTION(MediaInstallationUnit::GetFinishText);
  90. message = String::load(IDS_MEDIA_FINISH_TEXT);
  91. LOG_BOOL(true);
  92. return true;
  93. }
  94. String
  95. MediaInstallationUnit::GetServiceDescription()
  96. {
  97. LOG_FUNCTION(MediaInstallationUnit::GetServiceDescription);
  98. unsigned int resourceID = static_cast<unsigned int>(-1);
  99. if (IsServiceInstalled())
  100. {
  101. resourceID = IDS_MEDIA_SERVER_DESCRIPTION_INSTALLED;
  102. }
  103. else
  104. {
  105. resourceID = descriptionID;
  106. }
  107. ASSERT(resourceID != static_cast<unsigned int>(-1));
  108. return String::load(resourceID);
  109. }