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.

58 lines
2.0 KiB

  1. #ifndef _ISEXCHNG_H
  2. #define _ISEXCHNG_H
  3. inline BOOL _IsExchangeInstalled() // cloned in/from icw.cpp
  4. { // according to Chandramouli Venkatesh:
  5. /*
  6. look for a non-empty string pointing to a valid install dir under
  7. \HKLM\Software\Microsoft\Exchange\Setup\Services
  8. to distinguish PT from 5.5, look under
  9. \HKLM\Software\Microsoft\Exchange\Setup\newestBuildKey
  10. this has the build #.
  11. */
  12. BOOL b = FALSE;
  13. HKEY hk;
  14. HRESULT hr = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  15. L"Software\\Microsoft\\Exchange\\Setup",
  16. 0, KEY_READ, &hk);
  17. if (hr == S_OK) {
  18. WCHAR szPath[MAX_PATH];
  19. szPath[0] = 0;
  20. DWORD dwType, dwSize = sizeof(szPath);
  21. hr = RegQueryValueEx (hk, // key
  22. L"Services",
  23. NULL, // reserved
  24. &dwType, // address of type
  25. (LPBYTE)szPath, // address of buffer
  26. &dwSize); // address of size
  27. // check if path is valid
  28. DWORD dwFlags = GetFileAttributes (szPath);
  29. if (dwFlags != (DWORD)-1)
  30. if (dwFlags & FILE_ATTRIBUTE_DIRECTORY)
  31. b = TRUE;
  32. if (b == TRUE) {
  33. // could be 5.5: let's check
  34. DWORD dwBuildNumber = 0;
  35. DWORD dwType, dwSize = sizeof(dwBuildNumber);
  36. hr = RegQueryValueEx (hk, // key
  37. L"NewestBuild",
  38. NULL, // reserved
  39. &dwType, // address of type
  40. (LPBYTE)&dwBuildNumber, // address of buffer
  41. &dwSize); // address of size
  42. if (hr == S_OK) {
  43. if (dwBuildNumber < 4047) // PT beta 1 build
  44. b = FALSE;
  45. }
  46. }
  47. RegCloseKey (hk);
  48. }
  49. return b;
  50. }
  51. #endif