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.

100 lines
2.1 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: WINSInstallationUnit.cpp
  4. //
  5. // Synopsis: Defines a WINSInstallationUnit
  6. // This object has the knowledge for installing the
  7. // WINS service
  8. //
  9. // History: 02/06/2001 JeffJon Created
  10. #include "pch.h"
  11. #include "resource.h"
  12. #include "WINSInstallationUnit.h"
  13. WINSInstallationUnit::WINSInstallationUnit() :
  14. NetworkServiceInstallationBase(
  15. IDS_WINS_SERVER_TYPE,
  16. IDS_WINS_SERVER_DESCRIPTION,
  17. IDS_WINS_SERVER_DESCRIPTION_INSTALLED,
  18. WINS_INSTALL)
  19. {
  20. LOG_CTOR(WINSInstallationUnit);
  21. }
  22. WINSInstallationUnit::~WINSInstallationUnit()
  23. {
  24. LOG_DTOR(WINSInstallationUnit);
  25. }
  26. InstallationReturnType
  27. WINSInstallationUnit::InstallService(HANDLE logfileHandle, HWND /*hwnd*/)
  28. {
  29. LOG_FUNCTION(WINSInstallationUnit::InstallService);
  30. InstallationReturnType result = INSTALL_SUCCESS;
  31. // Create the inf and unattend files that are used by the
  32. // Optional Component Manager
  33. String infFileText;
  34. String unattendFileText;
  35. CreateInfFileText(infFileText, IDS_WINS_INF_WINDOW_TITLE);
  36. CreateUnattendFileText(unattendFileText, CYS_WINS_SERVICE_NAME);
  37. // Install the service through the Optional Component Manager
  38. bool ocmResult = InstallServiceWithOcManager(infFileText, unattendFileText);
  39. if (ocmResult &&
  40. IsServiceInstalled())
  41. {
  42. // Log the successful installation
  43. LOG(L"WINS was installed successfully");
  44. CYS_APPEND_LOG(String::load(IDS_LOG_INSTALL_WINS_SUCCESS));
  45. }
  46. else
  47. {
  48. // Log the failure
  49. LOG(L"WINS failed to install");
  50. CYS_APPEND_LOG(String::load(IDS_LOG_WINS_INSTALL_FAILED));
  51. result = INSTALL_FAILURE;
  52. }
  53. LOG_INSTALL_RETURN(result);
  54. return result;
  55. }
  56. bool
  57. WINSInstallationUnit::IsServiceInstalled()
  58. {
  59. LOG_FUNCTION(WINSInstallationUnit::IsServiceInstalled);
  60. bool result = IsServiceInstalledHelper(CYS_WINS_SERVICE_NAME);
  61. LOG_BOOL(result);
  62. return result;
  63. }
  64. bool
  65. WINSInstallationUnit::GetFinishText(String& message)
  66. {
  67. LOG_FUNCTION(WINSInstallationUnit::GetFinishText);
  68. message = String::load(IDS_WINS_FINISH_TEXT);
  69. LOG_BOOL(true);
  70. return true;
  71. }