作者motai (啥昵称??)
看板C_Sharp
标题[问题] 更改预设浏览器
时间Fri Apr 6 18:14:54 2012
我作业系统是Win7 (64位元)
网路上找的资讯都是说在以下的注册表位置
HKEY_CLASSES_ROOT\http\shell\open\command
里的value值设为
C:\Program Files\Internet Explorer\iexplore.exe
但我用Google浏览器跟IE交互设定预设浏览器
那value值也不会改变..(预设浏览器有变)
後来在HKEY_USERS\S-1-5-21-3076430924-96...(一长串)\...\.....
下发现有个值是存预设浏览器的名称
会随着改预设浏览器而跟着变
但搜寻Internet Explorer\iexplore.exe或Google的会搜出一大堆
不知道哪个才是存预设浏览器路径....
请问有谁知道怎麽找到她存路径的地方呢?
------------------------------------------------
以下是程式码:
//判断路径上的Program Files是否要加"(x86)"
RegistryKey key = Registry.LocalMachine.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
string CPUTag = key.GetValue("Identifier").ToString();
string mainKey = @"http\shell\open\command"; //预设浏览器路径的注册位置
string nameKey = @"http\shell\open\ddeexec\Application"; //预设浏览器名称的注册位置
string IEPath;
if(CPUTag.Substring(5,2)=="64")
IEPath = @"C:\Program Files (x86)\Internet Explorer\iexplore.exe";
else
IEPath = @"C:\Program Files\Internet Explorer\iexplore.exe";
bool result = false;
try
{
string value = string.Format("\"{0}\" -- \"%1\"", IEPath);
RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(mainKey, true);
regKey.SetValue("", value);
regKey.Close();
regKey = Registry.ClassesRoot.OpenSubKey(nameKey, true);
regKey.SetValue("", "IExplore");
regKey.Close();
result = true;
MessageBox.Show("预设浏览器已设为IE浏览器!","设定");
}
catch
{
MessageBox.Show("设定预设浏览器失败。!", "设定");
}
return result;
--
This is SPARTA!
我只是要土和水
拿来种种花啊!!! \固
囧//☆︿异╲
█ ☆ \ by aokman
████████◤ \\ ◥██aokman███████████████
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 60.248.105.178
1F:→ motai:请问有哪位高手知道的吗 @ @? 04/09 19:15