Add a method to detect the presence of the .NET Framework

This commit is contained in:
Paul Betts
2014-07-29 14:12:49 +02:00
parent 5a13008a68
commit 89f6e374ed
4 changed files with 38 additions and 1 deletions

27
src/Setup/FxHelper.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "stdafx.h"
#include "FxHelper.h"
CFxHelper::CFxHelper() { }
CFxHelper::~CFxHelper() { }
// http://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx#net_b
const wchar_t* ndpPath = L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full";
const int fx45ReleaseVersion = 378389;
bool CFxHelper::IsDotNet45OrHigherInstalled(void)
{
ATL::CRegKey key;
if (key.Open(HKEY_LOCAL_MACHINE, ndpPath, KEY_READ) != ERROR_SUCCESS) {
DWORD dwErr = GetLastError();
return false;
}
DWORD dwReleaseInfo = 0;
if (key.QueryDWORDValue(L"Release", dwReleaseInfo) != ERROR_SUCCESS ||
dwReleaseInfo < fx45ReleaseVersion) {
return false;
}
return true;
}

8
src/Setup/FxHelper.h Normal file
View File

@@ -0,0 +1,8 @@
#pragma once
class CFxHelper
{
public:
CFxHelper();
~CFxHelper();
static bool IsDotNet45OrHigherInstalled(void);
};

View File

@@ -86,12 +86,14 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="FxHelper.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="Setup.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="FxHelper.cpp" />
<ClCompile Include="winmain.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>

View File

@@ -20,7 +20,7 @@
#include <atlbase.h>
#include <atlapp.h>
#include <atldlgs.h>
#include <atlwin.h>
#if defined _M_IX86