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.

106 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: M A I N . C P P
  7. //
  8. // Contents: Code to provide a simple cmdline interface to
  9. // the sample code functions
  10. //
  11. // Notes: The code in this file is not required to access any
  12. // netcfg functionality. It merely provides a simple cmdline
  13. // interface to the sample code functions provided in
  14. // file snetcfg.cpp.
  15. //
  16. // Author: kumarp 28-September-98
  17. //
  18. //----------------------------------------------------------------------------
  19. #include "pch.h"
  20. #pragma hdrstop
  21. #include "snetcfg.h"
  22. #include <wbemcli.h>
  23. #include <winnls.h>
  24. #include "tracelog.h"
  25. BOOL g_fVerbose=FALSE;
  26. BOOL WlbsCheckSystemVersion ();
  27. BOOL WlbsCheckFiles ();
  28. HRESULT WlbsRegisterDlls ();
  29. HRESULT WlbsCompileMof ();
  30. // ----------------------------------------------------------------------
  31. //
  32. // Function: wmain
  33. //
  34. // Purpose: The main function
  35. //
  36. // Arguments: standard main args
  37. //
  38. // Returns: 0 on success, non-zero otherwise
  39. //
  40. // Author: kumarp 25-December-97
  41. //
  42. // Notes:
  43. //
  44. EXTERN_C int __cdecl wmain (int argc, WCHAR * argv[]) {
  45. HRESULT hr=S_FALSE;
  46. WCHAR szFileFullPath[MAX_PATH+1];
  47. WCHAR szFileFullPathDest[MAX_PATH+1];
  48. if (!WlbsCheckSystemVersion()) {
  49. LOG_ERROR("The NLB install pack can only be used on Windows 2000 Server Service Pack 1 or higher.");
  50. return S_OK;
  51. }
  52. /* Check to see if the service is already installed. */
  53. hr = FindIfComponentInstalled(_TEXT("ms_wlbs"));
  54. if (hr == S_OK) {
  55. LOG_INFO("Network Load Balancing Service is installed. Proceeding with uninstall...");
  56. } else {
  57. LOG_ERROR("Network Load Balancing Service is not installed.");
  58. return S_OK;
  59. }
  60. /* Now uninstall the service. */
  61. hr = HrUninstallNetComponent(L"ms_wlbs");
  62. if (!SUCCEEDED(hr))
  63. LOG_ERROR("Error uninstalling Network Load Balancing.");
  64. else
  65. LOG_INFO("Uninstallation of Network Load Balancing succeeded.");
  66. /* Remove the .inf and the .pnf files. */
  67. GetWindowsDirectory(szFileFullPathDest, MAX_PATH + 1);
  68. wcscat(szFileFullPathDest, L"\\INF\\netwlbs.inf");
  69. DeleteFile(szFileFullPathDest);
  70. GetWindowsDirectory(szFileFullPathDest, MAX_PATH + 1);
  71. wcscat(szFileFullPathDest, L"\\INF\\netwlbs.pnf");
  72. DeleteFile(szFileFullPathDest);
  73. return hr;
  74. }
  75. /* This checks whether the system on which NLB is being installed is a W2K Server or not. */
  76. BOOL WlbsCheckSystemVersion () {
  77. OSVERSIONINFOEX osinfo;
  78. osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  79. if (!GetVersionEx((LPOSVERSIONINFO)&osinfo)) return FALSE;
  80. /* For uninstalls, we return TRUE only if its Windows 2000 Server. */
  81. if ((osinfo.dwMajorVersion == 5) &&
  82. (osinfo.dwMinorVersion == 0) &&
  83. (osinfo.wProductType == VER_NT_SERVER) &&
  84. !(osinfo.wSuiteMask & VER_SUITE_ENTERPRISE) &&
  85. !(osinfo.wSuiteMask & VER_SUITE_DATACENTER))
  86. return TRUE;
  87. return FALSE;
  88. }