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.

92 lines
2.3 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: cmver.cpp
  4. //
  5. // Module: CMSETUP.LIB
  6. //
  7. // Synopsis: Implementation of CmVersion class, a utility class that
  8. // helps in detecting the version of Connection Mananger that
  9. // is installed.
  10. //
  11. // Copyright (c) 1998-1999 Microsoft Corporation
  12. //
  13. // Author: a-anasj Created 02/11/98
  14. // quintinb Cleaned Up and removed CRegValue 07/14/98
  15. // quintinb Rewrote 09/14/98
  16. //
  17. //+----------------------------------------------------------------------------
  18. #include "cmsetup.h"
  19. #include "reg_str.h"
  20. CmVersion::CmVersion()
  21. {
  22. HKEY hKey;
  23. LONG lResult;
  24. m_szCmmgrPath[0] = TEXT('\0');
  25. //
  26. // We always want to look in the system directory for cmmgr32.exe first. This is
  27. // its new install location and the app paths key may be corrupted by a 1.0 profile
  28. // install.
  29. //
  30. MYVERIFY(0 != GetSystemDirectory(m_szCmmgrPath, CELEMS(m_szCmmgrPath)));
  31. MYVERIFY(CELEMS(m_szPath) > (UINT)wsprintf(m_szPath, TEXT("%s\\cmdial32.dll"),
  32. m_szCmmgrPath));
  33. if (!FileExists(m_szPath))
  34. {
  35. //
  36. // The file wasn't in the system directory, now try the app paths key
  37. //
  38. m_szCmmgrPath[0] = TEXT('\0');
  39. m_szPath[0] = TEXT('\0');
  40. lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, c_pszRegCmAppPaths, 0, KEY_READ, &hKey);
  41. if (ERROR_SUCCESS == lResult)
  42. {
  43. //
  44. // Check to see if we have a path to work from.
  45. //
  46. DWORD dwSize = MAX_PATH;
  47. DWORD dwType = REG_SZ;
  48. if (ERROR_SUCCESS == RegQueryValueEx(hKey, c_pszRegPath, NULL, &dwType,
  49. (LPBYTE)m_szCmmgrPath, &dwSize))
  50. {
  51. //
  52. // Now construct the base object
  53. //
  54. MYVERIFY(CELEMS(m_szPath) > (UINT)wsprintf(m_szPath, TEXT("%s\\cmdial32.dll"),
  55. m_szCmmgrPath));
  56. Init();
  57. }
  58. RegCloseKey(hKey);
  59. }
  60. }
  61. else
  62. {
  63. Init();
  64. }
  65. }
  66. CmVersion::~CmVersion()
  67. {
  68. // nothing to do really
  69. }
  70. BOOL CmVersion::GetInstallLocation(LPTSTR szStr)
  71. {
  72. if ((m_bIsPresent) && (TEXT('\0') != m_szCmmgrPath[0]) && (NULL != szStr))
  73. {
  74. lstrcpy(szStr, m_szCmmgrPath);
  75. }
  76. return m_bIsPresent;
  77. }