diff options
Diffstat (limited to 'Source/cmVSSetupHelper.h')
-rw-r--r-- | Source/cmVSSetupHelper.h | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/Source/cmVSSetupHelper.h b/Source/cmVSSetupHelper.h index d2f514c63..0980cef53 100644 --- a/Source/cmVSSetupHelper.h +++ b/Source/cmVSSetupHelper.h @@ -4,17 +4,17 @@ #define cmVSSetupHelper_h #ifndef NOMINMAX -#define NOMINMAX // Undefine min and max defined by windows.h +# define NOMINMAX // Undefine min and max defined by windows.h #endif // Published by Visual Studio Setup team -#include "cmvssetup/Setup.Configuration.h" - #include <string> #include <vector> #include <windows.h> +#include "cmvssetup/Setup.Configuration.h" + template <class T> class SmartCOMPtr { @@ -74,29 +74,12 @@ class SmartBSTR { public: SmartBSTR() { str = NULL; } - SmartBSTR(const SmartBSTR& src) - { - if (src.str != NULL) { - str = ::SysAllocStringByteLen((char*)str, ::SysStringByteLen(str)); - } else { - str = ::SysAllocStringByteLen(NULL, 0); - } - } - SmartBSTR& operator=(const SmartBSTR& src) - { - if (str != src.str) { - ::SysFreeString(str); - if (src.str != NULL) { - str = ::SysAllocStringByteLen((char*)str, ::SysStringByteLen(str)); - } else { - str = ::SysAllocStringByteLen(NULL, 0); - } - } - return *this; - } + SmartBSTR(const SmartBSTR& src) = delete; + SmartBSTR& operator=(const SmartBSTR& src) = delete; operator BSTR() const { return str; } BSTR* operator&() throw() { return &str; } ~SmartBSTR() throw() { ::SysFreeString(str); } + private: BSTR str; }; @@ -106,26 +89,25 @@ struct VSInstanceInfo std::wstring InstanceId; std::wstring VSInstallLocation; std::wstring Version; - ULONGLONG ullVersion; - bool IsWin10SDKInstalled; - bool IsWin81SDKInstalled; + std::string VCToolsetVersion; + ULONGLONG ullVersion = 0; + bool IsWin10SDKInstalled = false; + bool IsWin81SDKInstalled = false; - VSInstanceInfo() - { - InstanceId = VSInstallLocation = Version = L""; - ullVersion = 0; - IsWin10SDKInstalled = IsWin81SDKInstalled = false; - } + std::string GetInstallLocation() const; }; class cmVSSetupAPIHelper { public: - cmVSSetupAPIHelper(); + cmVSSetupAPIHelper(unsigned int version); ~cmVSSetupAPIHelper(); - bool IsVS2017Installed(); + bool SetVSInstance(std::string const& vsInstallLocation); + + bool IsVSInstalled(); bool GetVSInstanceInfo(std::string& vsInstallLocation); + bool GetVCToolsetVersion(std::string& vsToolsetVersion); bool IsWin10SDKInstalled(); bool IsWin81SDKInstalled(); @@ -134,11 +116,12 @@ private: bool GetVSInstanceInfo(SmartCOMPtr<ISetupInstance2> instance2, VSInstanceInfo& vsInstanceInfo); bool CheckInstalledComponent(SmartCOMPtr<ISetupPackageReference> package, - bool& bVCToolset, bool& bWin10SDK, - bool& bWin81SDK); + bool& bWin10SDK, bool& bWin81SDK); int ChooseVSInstance(const std::vector<VSInstanceInfo>& vecVSInstances); bool EnumerateAndChooseVSInstance(); + unsigned int Version; + // COM ptrs to query about VS instances SmartCOMPtr<ISetupConfiguration> setupConfig; SmartCOMPtr<ISetupConfiguration2> setupConfig2; @@ -149,6 +132,9 @@ private: HRESULT comInitialized; // current best instance of VS selected VSInstanceInfo chosenInstanceInfo; + bool IsEWDKEnabled(); + + std::string SpecifiedVSInstallLocation; }; #endif |