问题描述
我一直在 32 位上测试我的应用程序,它运行良好,但是一旦它切换到 64 位操作系统,就会出现问题
I have been testing my application on 32 bit and it is working fine but as soon it switches to 64 bit OS then there is a problem
它改变了一次代理但是再也不会保持和测试相同循环其余部分的代理
.我看到一些帖子表明 32 位和 64 位注册表存在一些差异,并且已经编写了代码,但它在 64 位环境中无法正常工作
.I came across some posts that shows that there is some difference bit 32 and 64 bit registry and have written a code but it dose not work well on 64 bit environment
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);
public bool Is64Bit()
{
bool retVal;
IsWow64Process(System.Diagnostics.Process.GetCurrentProcess().Handle, out retVal);
return retVal;
}
Microsoft.Win32.RegistryKey registry;
if (Is64Bit())
{
MessageBox.Show("Oh HO! you are running 64 bit version");
registry = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings", true);
}
else
{
MessageBox.Show("Yes it is 32 bit");
registry = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
}
string orignalProxyServer = registry.GetValue("ProxyServer").ToString();
int orignalProxyEnable = int.Parse(registry.GetValue("ProxyEnable").ToString());
int i = 0;
while (i < listBox1.Items.Count)
{
//Enter new proxies Settings//
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", listBox1.Items[i].ToString());
RefreshInternetExplorerSettings();
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.whatismyip.com/automation/n09230945.asp");
using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
{
resopnse = reader.ReadToEnd();
this.Invoke(new EventHandler(DoIe));
}
}
catch (Exception c)
{
MessageBox.Show(c.Message);
}
i++;
Application.DoEvents();
backgroundWorker1.ReportProgress(i);
}
registry.SetValue("ProxyEnable", orignalProxyEnable);
registry.SetValue("ProxyServer", orignalProxyServer);
RefreshInternetExplorerSettings();
推荐答案
似乎对 Internet Explorer 的版本和它使用的注册表节点有很大的依赖性:
It seems that there is quite a dependency on the version of Internet Explorer and the registry nodes it's using:
对于 Windows 基于 x86 的 计算机:
要更改机器范围的连接尝试:HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionInternet Settings
To change the machine-wide connection attempts: HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionInternet Settings
要更改特定于用户的连接尝试:HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet 设置
To change the user-specific connection attempts: HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings
对于 Windows 基于 x64 的 计算机:
For Windows x64-based computers:
要更改 32 位 Internet Explorer 的计算机范围连接尝试:HKEY_LOCAL_MACHINESoftwareWow6432NodeMicrosoftWindowsCurrentVersionInternet Settings
To change the machine-wide connection attempts for Internet Explorer 32-bit: HKEY_LOCAL_MACHINESoftwareWow6432NodeMicrosoftWindowsCurrentVersionInternet Settings
要更改 Internet Explorer 32 位 的特定于用户的连接尝试:HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet 设置
To change the user-specific connection attempts for Internet Explorer 32-bit: HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings
要更改 64 位 Internet Explorer 的计算机范围连接尝试:HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionInternet Settings
To change the machine-wide connection attempts for Internet Explorer 64-bit: HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionInternet Settings
要更改 Internet Explorer 64 位 的特定于用户的连接尝试:HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet 设置
To change the user-specific connection attempts for Internet Explorer 64-bit: HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings
来源:http://www.thewindowsclub.com/fix-internet-explorer-cannot-display-the-webpage#ixzz1DPF9FSvK
我建议您尝试为 x86 和 x64 系统使用相同的节点.
I would recommend you to try and use the same node for x86 and x64 systems.
这篇关于为 win 7 64 位更改 IE c# 的代理(使用 httperbrequest 进行测试以确保注册表更改)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!