几款浏览器的安装路径
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; }
以前需要获取浏览器的安装路径,总结的
目前就找了六款,保存以备后用
相关文章推荐
- selenium 2 设置浏览器安装路径
- 同一台服务器,安装两个Tomcat,同一路径不同端口号,同一浏览器下不能同时访问问题
- ubuntu下通过浏览器下载软件包的路径及×××.tar.xz包的安装(1)
- Visual Studio安装项目中将用户选择的安装路径写入注册表的方法[转]
- [FUNC]如何取得 windows资源浏览器 的当前路径
- Advanced Installer,搜索注册表,根据注册表选择安装路径
- js判断浏览器是否安装了Flash插件及获取版本号
- C# 获取常见软件的安装路径(调用注册表)
- 把python安装到非默认路径
- 用注册表修改软件默认安装路径
- HTML:使用绝对路径插入图片后在浏览器中无法显示的问题
- Python:Anaconda安装虚拟环境到指定路径
- Windows服务的安装路径
- Linux如何查找文件安装路径
- CentOS 7 yum安装路径查询方法
- 如何获取应用程序的安装路径
- Ubuntu 下 Apache、php、mysql默认安装路径(以Ubuntu12.04为例)
- 判断浏览器是否安装ActiveX控件
- linux动态库的制作和路径安装
- 解决安装 Internet Download Manger@V6.0.9时集成浏览器的问题