您的位置:首页 > 其它

几款浏览器的安装路径

2011-02-17 10:37 120 查看
废话不说了,直接代码:

//由注册表取得软件安装路径
//没找到返回空值
CString CTesttApp::GetAppPath(CString strExe)
{
	HKEY   hKey;   
	LONG   lRes;   
	TCHAR   szPath[MAX_PATH]   =   {0};   
	DWORD   dwBufLen   =   MAX_PATH;   
	CString Path,strPath,strWork;
	//在HKEY_LOCAL_MACHINE, "SOFTWARE//Microsoft//Windows//CurrentVersion//Uninstall 路径
	if (_T("Maxthon.exe")==strExe)//遨游
	{
		lRes = RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows//CurrentVersion//Uninstall//Maxthon"), &hKey);   
		if(lRes != ERROR_SUCCESS)   
		{   
			RegCloseKey(hKey);
			lRes = RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows//CurrentVersion//Uninstall//Maxthon2"), &hKey);
			if(lRes != ERROR_SUCCESS)   
			{
				RegCloseKey(hKey);
				return _T("");  
			}
		}   
		DWORD dwType = REG_SZ;   
		lRes = RegQueryValueEx(hKey,   _T("DisplayIcon"),   NULL,   &dwType,   (LPBYTE)szPath,   &dwBufLen); 		
		RegCloseKey(hKey);
		CString str = szPath;
		int index = str.ReverseFind('//');
		str = str.Left(index+1);
		str +=_T("Maxthon.exe");
		_tcscpy(szPath,str.GetBuffer(0));
	}
	else if (_T("ttraveler.exe")==strExe)//腾讯TT
	{
		lRes = RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows//CurrentVersion//Uninstall//Tencent Traveler"), &hKey);   
		if(lRes != ERROR_SUCCESS)   
		{   
			RegCloseKey(hKey);
			return _T("");  
		}   
		DWORD dwType = REG_SZ;   
		lRes = RegQueryValueEx(hKey,   _T("DisplayIcon"),   NULL,   &dwType,   (LPBYTE)szPath,   &dwBufLen); 		
		RegCloseKey(hKey);
	}
	//IE
	else if (_T("iexplore.exe")==strExe)
	{
		_tcscpy(szPath,_T("C://Program Files//Internet Explorer//IEXPLORE.EXE"));
	}
	//在HKEY_LOCAL_MACHINE, "SOFTWARE//Microsoft//Windows//CurrentVersion//App Paths 路径
	else if (_T("360SE.exe")==strExe)//360
	{
		lRes = RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows//CurrentVersion//App Paths//360se 3.exe"), &hKey);   
		if(lRes != ERROR_SUCCESS)   
		{   
			RegCloseKey(hKey);
			return _T("");  
		}   
		DWORD dwType = REG_SZ;   
		lRes = RegQueryValueEx(hKey,   _T(""),   NULL,   &dwType,   (LPBYTE)szPath,   &dwBufLen); 		
		RegCloseKey(hKey);
	}
	else if (_T("TheWorld.exe")==strExe)//世界之窗
	{
		lRes = RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows//CurrentVersion//App Paths//TheWorld.exe"), &hKey);   
		if(lRes != ERROR_SUCCESS)   
		{   
			RegCloseKey(hKey);
			lRes = RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows//CurrentVersion//Uninstall//{CBE331E3-CB6B-46a3-A669-2C6DABBA2601}"), &hKey);
			if(lRes != ERROR_SUCCESS)   
			{
				RegCloseKey(hKey);
				return _T("");  
			}
			DWORD dwType = REG_SZ;   
			lRes = RegQueryValueEx(hKey,   _T("UninstallString"),   NULL,   &dwType,   (LPBYTE)szPath,   &dwBufLen); 		
			RegCloseKey(hKey);
			CString str = szPath;
			int index = str.ReverseFind('//');
			str = str.Left(index+1);
			str +=_T("TheWorld.exe");
			_tcscpy(szPath,str.GetBuffer(0));
		}   
		else
		{
			DWORD dwType = REG_SZ;   
			lRes = RegQueryValueEx(hKey,   _T(""),   NULL,   &dwType,   (LPBYTE)szPath,   &dwBufLen); 		
			RegCloseKey(hKey);
		}
	}
	else if (_T("chrome.exe")==strExe)//谷歌Chrome
	{
		lRes = RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows//CurrentVersion//App Paths//chrome.exe"), &hKey);   
		if(lRes != ERROR_SUCCESS)   
		{   
			RegCloseKey(hKey);
			return _T("");  
		}   
		DWORD dwType = REG_SZ;   
		lRes = RegQueryValueEx(hKey,   _T(""),   NULL,   &dwType,   (LPBYTE)szPath,   &dwBufLen); 		
		RegCloseKey(hKey);
	}
	else if (_T("firefox.exe")==strExe)//火狐FireFox
	{
		lRes = RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows//CurrentVersion//App Paths//firefox.exe"), &hKey);   
		if(lRes != ERROR_SUCCESS)   
		{   
			RegCloseKey(hKey);
			lRes = RegOpenKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Mozilla//Mozilla Firefox 2.0.0.20//bin"), &hKey);
			if(lRes != ERROR_SUCCESS)   
			{
				RegCloseKey(hKey);
				return _T("");  
			}
			DWORD dwType = REG_SZ;   
			lRes = RegQueryValueEx(hKey,   _T("PathToExe"),   NULL,   &dwType,   (LPBYTE)szPath,   &dwBufLen); 		
			RegCloseKey(hKey);
		}  
		else
		{
			DWORD dwType = REG_SZ;   
			lRes = RegQueryValueEx(hKey,   _T(""),   NULL,   &dwType,   (LPBYTE)szPath,   &dwBufLen); 		
			RegCloseKey(hKey);
		}
	}
	//////////////////////////////////////////////////////////////////////////
	strPath = szPath;
	if (strPath.IsEmpty())
	{
		return _T("");
	}
	//判断该文件是否存在
	if (FileExteriorFile(strPath))
	{
		Path = strPath;
	}
	else
	{
		Path = _T("");
	}
	return Path;
}
//查找指定的文件是否存在
//不存在返回FALSE 存在返回TRUE
BOOL CTestApp::FileExteriorFile(LPCTSTR FileName)
{
	WIN32_FIND_DATA fd;
	HANDLE hd=::FindFirstFile(FileName,&fd);//开始查找
	if(hd==INVALID_HANDLE_VALUE)
	{
		return FALSE;
	}
	FindClose(hd);//关闭查找
	return TRUE;
}




以前需要获取浏览器的安装路径,总结的

目前就找了六款,保存以备后用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: