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.

139 lines
4.4 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: detect.h
  6. //
  7. // Purpose: Component Detection
  8. //
  9. // History: 3/9/99 YAsmi Created
  10. //
  11. //=======================================================================
  12. #ifndef _DETECT_H
  13. #define _DETECT_H
  14. #include "stdafx.h"
  15. #include <v3stdlib.h>
  16. #include <inseng.h>
  17. #define COMPONENT_KEY _T("Software\\Microsoft\\Active Setup\\Installed Components")
  18. #define UNINSTALL_BRANCH _T("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall")
  19. #define DEFAULT_LOCALE _T("en")
  20. #define ISINSTALLED_KEY _T("IsInstalled")
  21. #define LOCALE_KEY _T("Locale")
  22. #define VERSION_KEY _T("Version")
  23. #define BUILD_KEY _T("Build")
  24. #define QFE_VERSION_KEY _T("QFEVersion")
  25. #define ISINSTALLED_YES 1
  26. #define ISINSTALLED_NO 0
  27. void ConvertVersionStrToDwords(LPCTSTR pszVer, LPDWORD pdwVer, LPDWORD pdwBuild);
  28. BOOL GetFileVersionDwords(LPCTSTR pszFilename, LPDWORD pdwMSVer, LPDWORD pdwLSVer);
  29. //
  30. // CComponentDetection class
  31. //
  32. class CComponentDetection : public ICifComponent
  33. {
  34. public:
  35. enum enumCCValue
  36. {
  37. ccGUID = 0,
  38. ccVersion = 1,
  39. ccUninstallKey = 2,
  40. ccDetectVersion = 3,
  41. ccRegKeyVersion = 4,
  42. ccLocale = 5,
  43. ccQFEVersion = 6,
  44. ccCustomData = 7,
  45. ccLastValue = 7
  46. };
  47. CComponentDetection();
  48. virtual ~CComponentDetection();
  49. BOOL SetValue(enumCCValue cc, LPCSTR pszValue);
  50. BOOL GetValue(enumCCValue cc, LPSTR pszValue, DWORD dwSize);
  51. DWORD Detect();
  52. DWORD GetLastDetectStatus();
  53. DWORD GetLastDLLReturnValue();
  54. void GetInstalledVersion(LPDWORD pdwVer, LPDWORD pdwBuild);
  55. //
  56. // ICifComponent interface (not a COM interface)
  57. //
  58. STDMETHOD(GetID)(LPSTR pszID, DWORD dwSize);
  59. STDMETHOD(GetGUID)(LPSTR pszGUID, DWORD dwSize);
  60. STDMETHOD(GetDescription)(LPSTR pszDesc, DWORD dwSize);
  61. STDMETHOD(GetDetails)(LPSTR pszDetails, DWORD dwSize);
  62. STDMETHOD(GetUrl)(UINT uUrlNum, LPSTR pszUrl, DWORD dwSize, LPDWORD pdwUrlFlags);
  63. STDMETHOD(GetFileExtractList)(UINT uUrlNum, LPSTR pszExtract, DWORD dwSize);
  64. STDMETHOD(GetUrlCheckRange)(UINT uUrlNum, LPDWORD pdwMin, LPDWORD pdwMax);
  65. STDMETHOD(GetCommand)(UINT uCmdNum, LPSTR pszCmd, DWORD dwCmdSize, LPSTR pszSwitches,
  66. DWORD dwSwitchSize, LPDWORD pdwType);
  67. STDMETHOD(GetVersion)(LPDWORD pdwVersion, LPDWORD pdwBuild);
  68. STDMETHOD(GetLocale)(LPSTR pszLocale, DWORD dwSize);
  69. STDMETHOD(GetUninstallKey)(LPSTR pszKey, DWORD dwSize);
  70. STDMETHOD(GetInstalledSize)(LPDWORD pdwWin, LPDWORD pdwApp);
  71. STDMETHOD_(DWORD, GetDownloadSize)();
  72. STDMETHOD_(DWORD, GetExtractSize)();
  73. STDMETHOD(GetSuccessKey)(LPSTR pszKey, DWORD dwSize);
  74. STDMETHOD(GetProgressKeys)(LPSTR pszProgress, DWORD dwProgSize,
  75. LPSTR pszCancel, DWORD dwCancelSize);
  76. STDMETHOD(IsActiveSetupAware)();
  77. STDMETHOD(IsRebootRequired)();
  78. STDMETHOD(RequiresAdminRights)();
  79. STDMETHOD_(DWORD, GetPriority)();
  80. STDMETHOD(GetDependency)(UINT uDepNum, LPSTR pszID, DWORD dwBuf, char *pchType, LPDWORD pdwVer, LPDWORD pdwBuild);
  81. STDMETHOD_(DWORD, GetPlatform)();
  82. STDMETHODIMP_(BOOL) DisableComponent();
  83. STDMETHOD(GetMode)(UINT uModeNum, LPSTR pszModes, DWORD dwSize);
  84. STDMETHOD(GetGroup)(LPSTR pszID, DWORD dwSize);
  85. STDMETHOD(IsUIVisible)();
  86. STDMETHOD(GetPatchID)(LPSTR pszID, DWORD dwSize);
  87. STDMETHOD(GetDetVersion)(LPSTR pszDLL, DWORD dwdllSize, LPSTR pszEntry, DWORD dwentSize);
  88. STDMETHOD(GetTreatAsOneComponents)(UINT uNum, LPSTR pszID, DWORD dwBuf);
  89. STDMETHOD(GetCustomData)(LPSTR pszKey, LPSTR pszData, DWORD dwSize);
  90. STDMETHOD_(DWORD, IsComponentInstalled)();
  91. STDMETHOD(IsComponentDownloaded)();
  92. STDMETHOD_(DWORD, IsThisVersionInstalled)(DWORD dwAskVer, DWORD dwAskBld, LPDWORD pdwVersion, LPDWORD pdwBuild);
  93. STDMETHOD_(DWORD, GetInstallQueueState)();
  94. STDMETHOD(SetInstallQueueState)(DWORD dwState);
  95. STDMETHOD_(DWORD, GetActualDownloadSize)();
  96. STDMETHOD_(DWORD, GetCurrentPriority)();
  97. STDMETHOD(SetCurrentPriority)(DWORD dwPriority);
  98. protected:
  99. enum {ccValueCount = (ccLastValue + 1), ccMaxSize = 256, ccDLLCount = 4};
  100. struct DLLCACHE
  101. {
  102. char szDLLName[32];
  103. HINSTANCE hLib;
  104. BOOL bUsed;
  105. };
  106. LPSTR m_ppValue[ccValueCount];
  107. DLLCACHE m_pDLLs[ccDLLCount];
  108. DWORD m_dwCustomDataSize;
  109. DWORD m_dwDetectStatus;
  110. DWORD m_dwDLLReturnValue;
  111. DWORD m_dwInstalledVer;
  112. DWORD m_dwInstalledBuild;
  113. void ClearValues();
  114. HRESULT CallDetectDLL(LPCSTR pszDll, LPCSTR pszEntry);
  115. HINSTANCE CacheLoadLibrary(LPCSTR pszDLLName, LPCTSTR pszDLLFullPath);
  116. };
  117. #endif //_DETECT_H