-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFramework.cpp
154 lines (128 loc) · 3.99 KB
/
Framework.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <windows.h>
#include "registrykeys.h"
#include "support.h"
void GetNetFx4xRelease(char* szRelease)
{
DWORD dwRelValue = 0;
lstrcpy(szRelease, "");
RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx4xRegKeyName, g_szNetfx4xReleaseRegValueName, NULL, (LPBYTE)&dwRelValue, sizeof(DWORD));
if (dwRelValue >= 528040)
lstrcpy(szRelease, "4.8");
else if (dwRelValue >= 461808)
lstrcpy(szRelease, "4.7.2");
else if (dwRelValue >= 461308)
lstrcpy(szRelease, "4.7.1");
else if (dwRelValue >= 460798)
lstrcpy(szRelease, "4.7");
else if (dwRelValue >= 394802)
lstrcpy(szRelease, "4.6.2");
else if (dwRelValue >= 394254)
lstrcpy(szRelease, "4.6.1");
else if (dwRelValue >= 393295)
lstrcpy(szRelease, "4.6");
else if (dwRelValue >= 379893)
lstrcpy(szRelease, "4.5.2");
else if (dwRelValue >= 378675)
lstrcpy(szRelease, "4.5.1");
else if (dwRelValue >= 378389)
lstrcpy(szRelease, "4.5");
}
bool IsNetfx4xInstalled()
{
DWORD dwRegValue = 0;
DWORD dwRelValue = 0;
if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx4xRegKeyName, g_szNetfx4xRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD)))
{
if (dwRegValue != 1)
return false;
if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx4xRegKeyName, g_szNetfx4xReleaseRegValueName, NULL, (LPBYTE)&dwRelValue, sizeof(DWORD)))
{
if (dwRelValue != 0)
return true;
}
}
return false;
}
bool IsNetfx40FullInstalled()
{
DWORD dwRegValue = 0;
if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx4xRegKeyName, g_szNetfx4xRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD)))
{
if (dwRegValue == 1)
return true;
}
return false;
}
bool IsNetfx40ClientInstalled()
{
DWORD dwRegValue = 0;
if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx4xClientRegKeyName, g_szNetfx4xRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD)))
{
if (dwRegValue == 1)
return true;
}
return false;
}
bool IsNetfx35Installed()
{
DWORD dwRegValue = 0;
if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx35RegKeyName, g_szNetfx35RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD)))
{
if (dwRegValue == 1)
return true;
}
return false;
}
bool IsNetfx30Installed()
{
DWORD dwRegValue = 0;
// look for original Net 3.0 install
if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx30OrigRegKeyName, g_szNetfx30OrigRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD)))
{
if (dwRegValue == 1)
return true;
}
// no original 3.0 install so look for 3.0sp1 install
// MS keeps changing registry keys!
if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx30RegKeyName, g_szNetfx30RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD)))
{
if (dwRegValue == 1)
return true;
}
return false;
}
bool IsNetfx20Installed()
{
DWORD dwRegValue = 0;
if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx20RegKeyName, g_szNetfx20RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD)))
{
if (dwRegValue == 1)
return true;
}
return false;
}
/******************************************************************
Uses the detection method recommended at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetdep/html/redistdeploy1_1.asp
to determine whether the .NET Framework 1.1 is installed on the machine
******************************************************************/
bool IsNetfx11Installed()
{
DWORD dwRegValue = 0;
if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx11RegKeyName, g_szNetfx11RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD)))
{
if (dwRegValue == 1)
return true;
}
return false;
}
/******************************************************************
Uses the detection method recommended at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetdep/html/dotnetfxref.asp
to determine whether the .NET Framework 1.0 is installed on the machine
******************************************************************/
bool IsNetfx10Installed()
{
TCHAR szRegValue[MAX_PATH];
return (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx10RegKeyName, g_szNetfx10RegKeyValue, NULL, (LPBYTE)szRegValue, MAX_PATH));
}