获取键值函数:
bool GetRegKey(HKEY key, CString strKeyPath, CString strKeyName, CString &strKeyVal)
{
HKEY hKey;
LONG lReturn;
bool bRet = false;
lReturn = ::RegOpenKeyEx(key, strKeyPath,0, KEY_READ, &hKey);
if (lReturn == ERROR_SUCCESS)
{
DWORD dwType;
wchar_t szPath[MAX_PATH];
DWORD cbData = sizeof(szPath);
lReturn = RegQueryValueEx(hKey, strKeyName, NULL, &dwType, (LPBYTE)szPath, &cbData);
if (lReturn == ERROR_SUCCESS && REG_SZ == dwType)
{
strKeyVal.Format(_T("%s"),szPath);
bRet = true;
}
RegCloseKey(hKey);
}
return bRet;
}
主调函数:
CString CWizardSheet::GetSystemInternetExplorerType(void)
{
bool bFindBrowser = false;
CString csExeName;
CString csType;
bFindBrowser = GetRegKey(HKEY_CURRENT_USER,_T("Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice"), _T("Progid"), csExeName);
if(bFindBrowser)
{
if (-1 != csExeName.FindOneOf(_T("IE")))
{
csType.Format(_T("IE"));
}
else
if (-1 != csExeName.Find(_T("Sogou Explorer")))
{
csType.Format(_T("Sogou Explorer"));
}
else
if (-1 != csExeName.Find(_T("Chrome")))
{
csType.Format(_T("Chrome"));
}
else
if (-1 != csExeName.Find(_T("Firefox")))
{
csType.Format(_T("Firefox"));
}
else
if (-1 != csExeName.Find(_T("Max")))
{
csType.Format(_T("Maxthon"));
} else
{
csType.Format(_T("%s"),csExeName);
}
}
return csType;
}