//獲取默認瀏覽器shell
BOOL CTestObjApp::InitInstance()瀏覽器
{ide
……………………………………string
bool findBrowser = false;
string strExeName;//得到的默認瀏覽器名稱
findBrowser = GetRegKey(HKEY_CLASSES_ROOT,"http\\shell\\open\\command", "", strExeName);it
……………………………………class
}command
//得到的默認瀏覽器名稱 方法實現方法
bool CTestObjApp::GetRegKey(HKEY key, string strKeyPath, string strKeyName, string &strKeyVal)
{
HKEY hKey;
LONG lReturn;
bool bRet = false;di
lReturn = ::RegOpenKeyEx(key, strKeyPath.c_str(),0, KEY_READ, &hKey);
if (lReturn == ERROR_SUCCESS)
{
DWORD dwType;
char szPath[MAX_PATH];
DWORD cbData = sizeof(szPath);view
lReturn = RegQueryValueEx(hKey, strKeyName.c_str(), NULL, &dwType, (LPBYTE)szPath, &cbData);
if (lReturn == ERROR_SUCCESS && REG_SZ == dwType)
{
strKeyVal = szPath;
bRet = true;
}
RegCloseKey(hKey);
}
return bRet;
}