using
System;
using
Microsoft.Win32;
public
class
GetDotNetVersion
{
public
static
void
Main()
{
(
".NET框架版本:"
);
using
(RegistryKey ndpKey = (,
""
).OpenSubKey(
@"SOFTWARE\Microsoft\NET Framework Setup\NDP\"
))
{
foreach
(
string
versionKeyName
in
())
{
if
((
"v"
))
{
RegistryKey versionKey = (versionKeyName);
string
name = (
string
)(
"Version"
,
""
);
string
sp = (
"SP"
,
""
).ToString();
string
install = (
"Install"
,
""
).ToString();
if
(install ==
""
)
//no install info, ust be later
(versionKeyName +
" "
+ name);
else
{
if
(sp !=
""
&& install ==
"1"
)
{
(versionKeyName +
" "
+ name +
" SP"
+ sp);
}
}
if
(name !=
""
)
{
continue
;
}
foreach
(
string
subKeyName
in
())
{
RegistryKey subKey = (subKeyName);
name = (
string
)(
"Version"
,
""
);
if
(name !=
""
)
sp = (
"SP"
,
""
).ToString();
install = (
"Install"
,
""
).ToString();
if
(install ==
""
)
//no install info, ust be later
(versionKeyName +
" "
+ name);
else
{
if
(sp !=
""
&& install ==
"1"
)
{
(
" "
+ subKeyName +
" "
+ name +
" SP"
+ sp);
}
else
if
(install ==
"1"
)
{
(
" "
+ subKeyName +
" "
+ name);
}
}
}
}
}
}
();
(
"操作系统版本:"
+ ());
(
"当前.NET框架版本:"
+ ());
();
}
}