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.

76 lines
3.8 KiB

  1. //////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // strstr.c
  4. //
  5. // This file contains most commonly used string operation. ALl the setup project should link here
  6. // or add the common utility here to avoid duplicating code everywhere or using CRT runtime.
  7. //
  8. // Created 4\15\997 inateeg got from shlwapi
  9. //
  10. ///////////////////////////////////////////////////////////////////////////////////////////////////
  11. #include <windows.h>
  12. #include "sdsutils.h"
  13. //=================================================================================================
  14. //
  15. //=================================================================================================
  16. #define NETWAREPATH "System\\CurrentControlSet\\Services\\Class\\NetClient\\"
  17. #define NETWARESUBKEY "Ndi"
  18. #define NETWAREVALUE "DeviceID"
  19. #define DNSLOADBALANCINGPATH "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"
  20. #define DNSLOADBALANCINGVALUE "DontUseDNSLoadBalancing"
  21. void DoPatchLoadBalancingForNetware( BOOL fRunningOnWin9X )
  22. {
  23. HKEY hNetWareSectionKey = NULL;
  24. HKEY hCurrentSubKey = NULL;
  25. HKEY hDNS_LoadBalancingKey = NULL;
  26. char szCurrSubKeyName[MAX_PATH] = { 0 };
  27. char szCurrentBuf[MAX_PATH] = { 0 };
  28. DWORD dwSize = sizeof(szCurrSubKeyName);
  29. DWORD dwDNSLoadBalancingData = 1;
  30. DWORD dwCurrentSection = 0;
  31. DWORD dwType = REG_SZ;
  32. LPSTR pNetWareName = "NOVELL";
  33. if ( fRunningOnWin9X )
  34. {
  35. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWAREPATH, 0, KEY_READ, &hNetWareSectionKey) )
  36. {
  37. while (ERROR_SUCCESS == RegEnumKeyEx(hNetWareSectionKey, dwCurrentSection, szCurrSubKeyName, &dwSize, NULL, NULL, NULL, NULL))
  38. {
  39. lstrcpy(szCurrentBuf, NETWAREPATH);
  40. AddPath(szCurrentBuf, szCurrSubKeyName);
  41. AddPath(szCurrentBuf, NETWARESUBKEY);
  42. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCSTR)szCurrentBuf, 0, KEY_QUERY_VALUE, &hCurrentSubKey))
  43. {
  44. dwSize = sizeof(szCurrentBuf);
  45. if (ERROR_SUCCESS == RegQueryValueEx(hCurrentSubKey, NETWAREVALUE, NULL, &dwType, (LPBYTE) szCurrentBuf, &dwSize))
  46. {
  47. if ((REG_SZ == dwType) && (0 == _strnicmp(pNetWareName, szCurrentBuf, lstrlen(pNetWareName))))
  48. {
  49. // The user has Novell's version of NetWare so we need to turn off DNS Load Balancing.
  50. if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE, DNSLOADBALANCINGPATH, 0, TEXT(""), 0,
  51. KEY_WRITE, NULL, &hDNS_LoadBalancingKey, NULL))
  52. {
  53. dwType = REG_DWORD;
  54. RegSetValueEx(hDNS_LoadBalancingKey, DNSLOADBALANCINGVALUE, 0, dwType, (CONST BYTE *) (&dwDNSLoadBalancingData), sizeof(dwDNSLoadBalancingData));
  55. RegCloseKey(hDNS_LoadBalancingKey);
  56. hDNS_LoadBalancingKey = NULL;
  57. RegCloseKey(hCurrentSubKey);
  58. break;
  59. }
  60. }
  61. }
  62. RegCloseKey(hCurrentSubKey);
  63. hCurrentSubKey = NULL;
  64. }
  65. dwCurrentSection++;
  66. dwSize = sizeof(szCurrSubKeyName);
  67. }
  68. RegCloseKey(hNetWareSectionKey);
  69. hNetWareSectionKey = NULL;
  70. }
  71. }
  72. }