This article provides a function to determine whether the. NET Framework environment is installed in the system. The function name is isnetpresent (). The working principle is to use the regopenkeyex API function to open the following registry key values in the current system:
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \. netframework \ Policy \ V1.0
If this registration item is found, use the regqueryvalueex API function to check whether the. NET Framework release version is:
3705
If both of the preceding conditions are met, the function returns true:
Bool isnetpresent ()
{
Bool bretval = false;
Tchar sznetregkey [] = text ("SOFTWARE \ Microsoft \. netframework \ Policy \ V1.0 ");
Tchar szvalue [max_path];
DWORD dwvalue = 0;
Hkey HKLM = NULL;
Long lreg = 0;
Long lszreg = 0;
DWORD dwkeysize = 0;
Lreg = regopenkeyex (HKEY_LOCAL_MACHINE,
Sznetregkey,
0,
Key_read,
& HKLM );
If (error_success = lreg)
{
Dwkeysize = sizeof (szvalue)/sizeof (tchar );
Lszreg = regqueryvalueex (HKLM, text ("3705"), null, null, (byte *) szvalue, & dwkeysize );
If (error_success = lszreg ))
{
Regclosekey (HKLM );
Return true;
}
Else
{
Regclosekey (HKLM );
Return false;
}
}
Else
{
Return false;
}
}
This article is an online excerpt. If you have any questions, you can discuss it together!