zipnotic
asked on
Reading and Writing Registry Key in 64 bit or 32 bit OS to force webbrowser control to IE9
Hello,
Google maps recently forced the site to use greater than IE7 standards making the webbrowser control (WB) not work with their website. The best solution seems to be modifying the registry to force the WB to use IE9 or 10 standards. I'm trying to modify my code so that the user machine on all profiles will use the IE 9 standard. I'd like to check if the following registry value is present and add it if it isn't in both 32 bit and 64 bit systems. I'm having trouble however and the junk code is my attempts so far.
Value to be added to wow64 OR 32 bit registry:
32 bit:
HKEY_LOCAL_MACHINE\SOFTWAR E\Microsof t\Internet Explorer\MAIN\FeatureContr ol\FEATURE _BROWSER_E MULATION
Value Key: yourapplication.exe
Type: Reg_DWORD
Value: 9999 (decimal)
64 bit:
HKEY_LOCAL_MACHINE\SOFTWAR E\Wow6432N ode\Micros oft\Intern et Explorer\MAIN\FeatureContr ol\FEATURE _BROWSER_E MULATION
Value Key: yourapplication.exe
Type: Reg_DWORD
Value: 9999 (decimal)
as suggested by this nice person:
http://www.west-wind.com/weblog/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version
Thanks for any help you can give
Google maps recently forced the site to use greater than IE7 standards making the webbrowser control (WB) not work with their website. The best solution seems to be modifying the registry to force the WB to use IE9 or 10 standards. I'm trying to modify my code so that the user machine on all profiles will use the IE 9 standard. I'd like to check if the following registry value is present and add it if it isn't in both 32 bit and 64 bit systems. I'm having trouble however and the junk code is my attempts so far.
Value to be added to wow64 OR 32 bit registry:
32 bit:
HKEY_LOCAL_MACHINE\SOFTWAR
Value Key: yourapplication.exe
Type: Reg_DWORD
Value: 9999 (decimal)
64 bit:
HKEY_LOCAL_MACHINE\SOFTWAR
Value Key: yourapplication.exe
Type: Reg_DWORD
Value: 9999 (decimal)
as suggested by this nice person:
http://www.west-wind.com/weblog/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version
Thanks for any help you can give
Try
Dim RK As RegistryKey = RegistryKey.openbasekey(RegistryHive.LocalMachine, registryview.registry64)
Dim key As RegistryKey = Registry.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", True)
Dim val As String()
val = key.GetValueNames()
key.SetValue("MYPROGRAM.EXE", "9999", RegistryValueKind.[String])
key.Close()
' HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
' [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]"YOURPROGRAM.EXE"=dword:00002328
'If Microsoft.Win32.Registry.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION") Is Nothing Then
' ' Key doesn't exist
' MsgBox("Key doesn't exist")
' Microsoft.Win32.Registry.LocalMachine.CreateSubKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION")
' Microsoft.Win32.Registry.LocalMachine.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", "9999")
'Else
' ' Key existed
'End If
Catch ex As Exception
End Try
ASKER
I'm reading about permissions in Windows 7, is that the problem when writing to Local Machine? Something about adding something to the manifest?
Yes, Windows 7 security limits access by default, unless you elevate privileges to administrator level.
Create and Embed an Application Manifest (UAC)
http://msdn.microsoft.com/en-us/library/bb756929.aspx
Create and Embed an Application Manifest (UAC)
http://msdn.microsoft.com/en-us/library/bb756929.aspx
ASKER
Looks like I have some reading to do.
Can you advise the best practice code (even just aircode) to ultimately write the following to the registry when the target machine may be
32 or 64
Win 7 or Win XP or Win 8
Users have no admin rights
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
SOFTWARE
Microsoft
Internet Explorer
Main
FeatureControl
FEATURE_BROWSER_EMULATION
MYAPPLICATIONNAME.exe = (DWORD) 00009000
Can you advise the best practice code (even just aircode) to ultimately write the following to the registry when the target machine may be
32 or 64
Win 7 or Win XP or Win 8
Users have no admin rights
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
SOFTWARE
Microsoft
Internet Explorer
Main
FeatureControl
FEATURE_BROWSER_EMULATION
MYAPPLICATIONNAME.exe = (DWORD) 00009000
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
to add to above comments:
if HKEY_CURRENT_USER would be an alternative, you should do it with that.
alternatively, you may think of a setup for your program that runs in admin mode and writes the entry to the registry.
Sara
if HKEY_CURRENT_USER would be an alternative, you should do it with that.
alternatively, you may think of a setup for your program that runs in admin mode and writes the entry to the registry.
Sara
ASKER
So far, writing to the CURRENT_USER seems cleaner. From what I understand the "registry director" will send the following entry to the right node automatically? I tried it on a win 7 64 bit machine and an XP 32 bit machine and so far so good but will there be any deployment problems I should anticipate? If not then this 'workaround' solution is a lot easier then I made it out to be...
The SetValue does nothing if the entry is already there, this is good.
The process is seamless to the user, this is good.
The webbrowser behaves, this is good.
The project is compiled for x86 while anyCPU breaks it, this is not so good, but tolerable.
Try
Dim instance3 As RegistryKey = Registry.CurrentUser.Creat eSubKey("S OFTWARE\Mi crosoft\In ternet Explorer\MAIN\FeatureContr ol\FEATURE _BROWSER_E MULATION", RegistryKeyPermissionCheck .ReadWrite SubTree)
instance3.SetValue(Applica tion.Execu tablePath. ToString() , 9999, RegistryValueKind.DWord)
instance3.SetValue("Iconic Resolution .vshost.ex e", 9999, RegistryValueKind.DWord) 'TODO Remove this line
instance3.Close()
Catch ex as exception
End Try
The SetValue does nothing if the entry is already there, this is good.
The process is seamless to the user, this is good.
The webbrowser behaves, this is good.
The project is compiled for x86 while anyCPU breaks it, this is not so good, but tolerable.
Try
Dim instance3 As RegistryKey = Registry.CurrentUser.Creat
instance3.SetValue(Applica
instance3.SetValue("Iconic
instance3.Close()
Catch ex as exception
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both. Learned's would probably work but Sara's is quicker and direct.
ASKER
If it means anything, VS 2010 is set to compile to x86. It doesn't give me any other option.
Also tried the simpler
' My.Computer.Registry.SetVa
but it resulted in a null object exception
Having a bit more success with:
Registry.LocalMachine.SetV
' RegistryKeyPermissionCheck
But that gives me permission denied exception (that's the closest I came so far to adding the key I need to).
The following only gives me "nothing" in the instances....
Open in new window