首页
社区
课程
招聘
[求助]默认浏览器设置成功同时.html文件图标关联也没错,但是打开.html文件仍是IE。。。问题出在哪里了呢?
发表于: 2012-10-8 18:29 6608

[求助]默认浏览器设置成功同时.html文件图标关联也没错,但是打开.html文件仍是IE。。。问题出在哪里了呢?

2012-10-8 18:29
6608
默认浏览器是IE,我设置成火狐,代码如下:(为了简化用的绝对路径)
		HKEY key;
			RegOpenKey(HKEY_CLASSES_ROOT,_T("Http\\shell\\open\\command"),&key);
			DWORD ret1=GetLastError();
			TCHAR val[]=_T("\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -requestPending -osint -url \"%1\"");
			RegSetValueEx(key,NULL,0,REG_EXPAND_SZ,(LPBYTE)val,sizeof(val));
			DWORD ret=GetLastError();
			RegCloseKey(key);
			RegOpenKey(HKEY_CLASSES_ROOT,_T("Http\\DefaultIcon"),&key);
			TCHAR val1_http[]=_T("C:\\Program Files\\Mozilla Firefox\\firefox.exe,1");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val1_http,sizeof(val1_http));
			RegCloseKey(key);
			RegOpenKey(HKEY_CLASSES_ROOT,_T("https\\shell\\open\\command"),&key);
			TCHAR val_https[]=_T("\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -requestPending -osint -url \"%1\"");
			RegSetValueEx(key,NULL,0,REG_EXPAND_SZ,(LPBYTE)val_https,sizeof(val_https));
			RegCloseKey(key);
			RegOpenKey(HKEY_CLASSES_ROOT,_T("https\\DefaultIcon"),&key);
			TCHAR val1_https[]=_T("C:\\Program Files\\Mozilla Firefox\\firefox.exe,1");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val1_https,sizeof(val1_https));
			RegCloseKey(key);
			RegOpenKey(HKEY_CLASSES_ROOT,_T("ftp\\shell\\open\\command"),&key);
			TCHAR val_1[]=_T("\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -requestPending -osint -url \"%1\"");
			RegSetValueEx(key,NULL,0,REG_EXPAND_SZ,(LPBYTE)val_1,sizeof(val_1));
			RegCloseKey(key);
			RegOpenKey(HKEY_CLASSES_ROOT,_T("ftp\\DefaultIcon"),&key);
			TCHAR val1[]=_T("C:\\Program Files\\Mozilla Firefox\\firefox.exe,1");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val1,sizeof(val1));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\.htm"),&key);
			TCHAR val2[]=_T("FirefoxHTML");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val2,sizeof(val2));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\.html"),&key);
			TCHAR val2_html[]=_T("FirefoxHTML");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val2_html,sizeof(val2_html));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\.shtml"),&key);
			TCHAR val2_shtml[]=_T("FirefoxHTML");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val2_shtml,sizeof(val2_shtml));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\.xht"),&key);
			TCHAR val2_xht[]=_T("FirefoxHTML");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val2_xht,sizeof(val2_xht));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\.xhtml"),&key);
			TCHAR val2_xhtml[]=_T("FirefoxHTML");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val2_xhtml,sizeof(val2_xhtml));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\ftp\\DefaultIcon"),&key);
			TCHAR val2_ftp[]=_T("C:\\Program Files\\Mozilla Firefox\\firefox.exe,1");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val2_ftp,sizeof(val2_ftp));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\http\\DefaultIcon"),&key);
			TCHAR val2_http[]=_T("C:\\Program Files\\Mozilla Firefox\\firefox.exe,1");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val2_http,sizeof(val2_http));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\https\\DefaultIcon"),&key);
			TCHAR val2_https[]=_T("C:\\Program Files\\Mozilla Firefox\\firefox.exe,1");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val2_https,sizeof(val2_https));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\https\\shell\\open\\command"),&key);
			TCHAR val2_https_1[]=_T("\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -requestPending -osint -url \"%1\"");
			RegSetValueEx(key,NULL,0,REG_EXPAND_SZ,(LPBYTE)val2_https_1,sizeof(val2_https_1));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\http\\shell\\open\\command"),&key);
			TCHAR val2_http_1[]=_T("\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -requestPending -osint -url \"%1\"");
			RegSetValueEx(key,NULL,0,REG_EXPAND_SZ,(LPBYTE)val2_http_1,sizeof(val2_http_1));
			RegCloseKey(key);
			RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Classes\\ftp\\shell\\open\\command"),&key);
			TCHAR val2_ftp_1[]=_T("\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -requestPending -osint -url \"%1\"");
			RegSetValueEx(key,NULL,0,REG_EXPAND_SZ,(LPBYTE)val2_ftp_1,sizeof(val2_ftp_1));
			RegCloseKey(key);
			//RegOpenKey(HKEY_CLASSES_ROOT,_T("HKEY_CLASSES_ROOT\\InternetShortcut\\shell\\open\\command"),&key);
			RegOpenKey(HKEY_CLASSES_ROOT,_T(".html"),&key);
			TCHAR val4[]=_T("FirefoxHTML");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val4,sizeof(val4));
			RegCloseKey(key);
			RegOpenKey(HKEY_CLASSES_ROOT,_T(".htm"),&key);
			TCHAR val5[]=_T("FirefoxHTML");
			RegSetValueEx(key,NULL,0,REG_SZ,(LPBYTE)val5,sizeof(val5));
			RegCloseKey(key);
			//刷新操作
			::SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,SPI_SETNONCLIENTMETRICS,0);

顺便说个小问题,用RegSetValue修改注册表内容不成功,改成RegSetValueEx修改OK,系统是xp sp3。代码运行后在QQ聊天窗口中打开www.xxx.com是用火狐了,打开xxx.html仍旧是IE打开的,另外在桌面右键刷新后xx.html文件的图标关联也是正确的(这步能在代码中实现吗?用代码替换掉F5的刷新操作?)

[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 446
活跃值: (186)
能力值: ( LV12,RANK:230 )
在线值:
发帖
回帖
粉丝
2
你看下 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html右边的值Application
要是win7的话看下HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice右边的值Progid
如果有的话删除掉,或者将值改为火狐的Progid
2012-10-9 07:24
0
雪    币: 132
活跃值: (214)
能力值: ( LV6,RANK:80 )
在线值:
发帖
回帖
粉丝
3
灰常感谢!
2012-10-9 09:43
0
游客
登录 | 注册 方可回帖
返回
//