I'm developing a desktop application, and I want to make a small browser with the possibilities of change the version of WebBrowser (obviously is IE).
I tried with change the registry of my application .exe, for example for this:
11001 (0x2AF9) or 7000 (0x1B58)
(Regkey.SetValue("myApp.exe", 0x1B58, RegistryValueKind.DWord);
If I do an "alert" of my WebBrowser, i get 11.xxxxx, but this never is changed.
I'm exhausted of try several things and nothing is working.
Someone has any idea about it?
Sorry for my english.
Thanks in advance.
Best regards,
Diego.
EDIT:
I tried with this:
RegistryKey Regkey32 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(#"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
RegistryKey Regkey64 = null;
if (Environment.Is64BitOperatingSystem)
{
Regkey64 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(#"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
}
Regkey32.SetValue(Path.GetFileName(Application.ExecutablePath), versionIE, RegistryValueKind.DWord);
if (Environment.Is64BitOperatingSystem)
{
Regkey64.SetValue(Path.GetFileName(Application.ExecutablePath), versionIE, RegistryValueKind.DWord);
}
MessageBox.Show(webBrowser1.Version.ToString())
Return: 11.0.9600.16428 (always)...
Is possible change this version when we are changing the registry?
Related
I want to set Lock Screen Wallpaper of Windows 10 and above from WPF application. I have searched and found the following links are useful.
https://stackoverflow.com/a/51785913/5523095
https://superuser.com/a/1274588
Based on the suggestion from the above answers I am trying to change the lock screen wallpaper using the following code.
RegistryKey key = Registry.CurrentUser.CreateSubKey(#"Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP", true);
key.SetValue(#"LockScreenImagePath", #"C:\Users\kumarm\Desktop\Wall.png");
key.SetValue(#"LockScreenImageUrl", #"C:\Users\kumarm\Desktop\Wall.png");
key.SetValue("LockScreenImageStatus", 1, RegistryValueKind.DWord);
key.Flush();
But the lock screen wallpaper is not changing. Am I doing anything wrong?
Your code creates the wrong key in the registry. Also instead of HKEY_LOCAL_MACHINE you use HKEY_CURRENT_USER. Should be like this:
RegistryKey key = Registry.LocalMachine.CreateSubKey(#"SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP", true);
key.SetValue(#"LockScreenImagePath", #"C:\Images\image.jpg");
key.SetValue(#"LockScreenImageUrl", #"C:\Images\image.jpg");
key.SetValue(#"LockScreenImageStatus", 1, RegistryValueKind.DWord);
key.Flush();
This code does work, but after that you cannot change the lock screen image in Windows settings - the possibility is blocked with the reference "Some of these settings are managed by your organization", which can be fixed by deleting registry keys or by setting empty "LockScreenImagePath" and "LockScreenImageUrl" values in the registry.
I keep getting a script error when trying to load the page using webBrowser.Navigate("https://home.nest.com/"). It will pull up fine from my normal internet browser but not in my program.
Can anyone point me in the right direction?
as this link answer:
you must only add this line:
webBrowser.ScriptErrorsSuppressed = true;
The script errors happen all of the time in the integrated Internet Explorer WebBrowser control even when it's using version 11. Modern websites rely heavily on massive Javascript files and dynamic rendering. You can see that just by watching that page load in a regular browser. The control just can't cut it some of the times.
You might want to try some alternative browser controls. There are no guarantees that it will work with any of them, but at least it's something to try.
Awesomium : Originally based on Chromium. I don't know if they still integrate Chromium changes or if they've gone in their own direction. It's free for personal use as well as commercial making less than $100k.
DotNetBrowser : Embed a Chromium-based WPF / WinForms component into your .NET application to display modern web pages built with HTML5, CSS3, JavaScript, Silverlight etc.
geckofx : An open-source component for embedding Mozilla Gecko (Firefox) in .NET applications.
Xilium.CefGlue : A .NET/Mono binding for The Chromium Embedded Framework (CEF) by Marshall A. Greenblatt.
BrowseEmAll : BrowseEmAll.Cef (Chrome), BrowseEmAll.Gecko (Firefox), BrowseEmAll Core API (Chrome,Firefox,IE - COMMERCIAL)
There are probably others, but this should give you a start with some of the more popular active projects if you want to pursue this route.
The WebBrowser control is capable of rendering most web pages, but by default it attempts to render pages in compatibility mode (pretty much IE7, hence the issues). If you are building your own page, it's simple, just add the following tag to the header and it should render fine...
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
However, if you are trying to render a third party site you cannot add tags to, things get more difficult. As mentioned above, you can use a registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION) if it's just on your own machine.
If neither of these options are a possible solution, using a different browser control (again, great suggestions above) is pretty much your only option.
There's a great blog on controlling the browser control compatibility mode at https://learn.microsoft.com/en-gb/archive/blogs/patricka/controlling-webbrowser-control-compatibility
You should add your program name to the register HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
for using the latest feature as same as your normal internet browser.
as for me, value 8000 (0x1F40) - IE8 mode can solve many script error problem.
Ref:
Use latest version of Internet Explorer in the webbrowser control
private void Form1_Load(object sender, EventArgs e)
{
var appName = Process.GetCurrentProcess().ProcessName + ".exe";
SetIE8KeyforWebBrowserControl(appName);
webBrowser1.ScriptErrorsSuppressed = true;
}
private void SetIE8KeyforWebBrowserControl(string appName)
{
RegistryKey Regkey = null;
try
{
// For 64 bit machine
if (Environment.Is64BitOperatingSystem)
Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(#"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
else //For 32 bit machine
Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(#"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
// If the path is not correct or
// if the user haven't priviledges to access the registry
if (Regkey == null)
{
MessageBox.Show("Application Settings Failed - Address Not found");
return;
}
string FindAppkey = Convert.ToString(Regkey.GetValue(appName));
// Check if key is already present
if (FindAppkey == "8000")
{
MessageBox.Show("Required Application Settings Present");
Regkey.Close();
return;
}
// If a key is not present add the key, Key value 8000 (decimal)
if (string.IsNullOrEmpty(FindAppkey))
Regkey.SetValue(appName, unchecked((int)0x1F40), RegistryValueKind.DWord);
// Check for the key after adding
FindAppkey = Convert.ToString(Regkey.GetValue(appName));
if (FindAppkey == "8000")
MessageBox.Show("Application Settings Applied Successfully");
else
MessageBox.Show("Application Settings Failed, Ref: " + FindAppkey);
}
catch (Exception ex)
{
MessageBox.Show("Application Settings Failed");
MessageBox.Show(ex.Message);
}
finally
{
// Close the Registry
if (Regkey != null)
Regkey.Close();
}
}
You may even set the registry value to 11000 to have the latest version of IE!!
I have a Surface Pro that I use for sketching with my stylus. I want to be able to quickly enable/disable tablet mode without going into Device Manager.
I've been searching for ways to do this: by disabling drivers, disabling by HID but everything I've found seems overly complicated for what I need. I'm creating just a form with a CheckBox. What's the simplest way to achieve this?
You could try something like setting the Registry Key to 0
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell]
"TabletMode"=dword:00000000
If TabletMode = 1 then it'll be enabled.
RegistryKey myKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell", true);
if(myKey != null)
{
myKey.SetValue("TabletMode", "0", RegistryValueKind.dWord);
myKey.Close();
}
Im developing a custom browser solution with .net's Webbrowser control.
To disable the IE-Compatibilty View, I set the registry entry
Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION:
[Sreenshot regedit] http://zbirk.mirk.at/browserreg.png "Screenshot"
i tried to use the values: dword=8000,dword=8888,dword=9000, but the webbrowser control seems to ignore these reg entries.
Maybe someone had this problems too and may help me.
The WebBrowser control definately DOES respect these keys.
Remember that while taskman may show application.exe in the name column, if you are debugging the exe name is application.vshost.exe
So in my application sI just attempt to create the key every time the app runs. If it fails to create it (because it already exists) then I continue running, if it creates the key then I inform the user that they need to restart the application.
ensure that you are not running within vshost
the app name would be different ie appname.vshost.exe
Thx for your reply, now its working.
Her is my working peace of code:
public void setIEcomp()
{
String appname = Process.GetCurrentProcess().ProcessName+".exe";
RegistryKey RK8 = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION",RegistryKeyPermissionCheck.ReadWriteSubTree);
int value9 = 9999;
int value8 = 8888;
Version ver = webBrowser1.Version;
int value = value9;
try
{
string[] parts = ver.ToString().Split('.');
int vn = 0;
int.TryParse(parts[0], out vn);
if (vn != 0)
{
if (vn == 9)
value = value9;
else
value = value8;
}
}
catch
{
value = value9;
}
//Setting the key in LocalMachine
if (RK8 != null)
{
try
{
RK8.SetValue(appname, value, RegistryValueKind.DWord);
RK8.Close();
}
catch(Exception ex)
{
//MessageBox.Show(ex.Message);
}
}
}
I too could not see that FEATURE_BROWSER_EMULATION made any difference in my application.
I was testing the FEATURE_BROWSER_EMULATION functionality by manually editing the registry with regedit. Nothing I did made any difference. My hosted page was still failing on any new-ish JavaScript and could not load external libraries.
I found my mistake:
I was editing the 64-bit view of the registry with regedit. My app was running as a 32-bit app and looking at the 32-bit view of the registry. That's why my changes to the registry seemed to have no impact on my application. By the way, the WPF project template defaults to "Prefer 32-bit."
Manually editing with regedit within the Wow6432Node key worked:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
Of course, setting the DWORD value programmatically within your application will also work, since your 32-bit application will edit within the Wow6432Node.
An older post and solution is no longer accurate.
Running procmon and watching for FEATURE_BROWSER_EMULATION shows the following registry variables actually checked. This was for WINWORD.exe but other than that - take your pick...
HKU\S-1-5-21-[my-sid-paws-off]\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\WINWORD.EXE
HKU\S-1-5-21-[my-sid-paws-off]\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION*
HKLM\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION(Default)
HKLM\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\WINWORD.EXE
HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\WINWORD.EXE
HKLM\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION*
HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION*
// Edit:
oh wow. It's odd that I've been working on this for a day now and just realized I needed to do:
key = key.OpenSubKey(#"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
And then everything worked. I did not know that you had to do that. Thanks for everyone that responded. I was just messing around and searched for my key and noticed it was being placed in the wrong spot.
// Original question:
I haven't seen a working solution for this and I'm not sure if it's a bug.
I have a C# 32-bit Windows service running on Windows 7 64-bit. My goal is to write to the 64-bit registry and not the Wow6432Node subkey since for AutoAdminLogon a 64-bit system doesn't seem to check the 32-bit view of the keys.
So my code is as follows:
static public void LoginAsGuest(EventLog eventLogger)
{
RegistrySecurity userSecurity = new RegistrySecurity();
RegistryAccessRule userRule = new RegistryAccessRule("Everyone", RegistryRights.FullControl, AccessControlType.Allow);
userSecurity.AddAccessRule(userRule);
var key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
key.OpenSubKey(#"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", RegistryKeyPermissionCheck.ReadWriteSubTree);
if (key == null)
{
eventLogger.WriteEntry("Error accessing the registry key");
}
else
{
try
{
key.SetValue("AutoAdminLogon", "1", RegistryValueKind.String);
key.SetValue("DefaultUserName", "guest", RegistryValueKind.String);
key.SetValue("DefaultPassword", "password", RegistryValueKind.String);
}
catch (Exception exception)
{
eventLogger.WriteEntry("Problem setting up keys: " + exception);
}
}
key.Close();
Reboot();
}
No exception or error is thrown. Nothing is written to the registry in the 32-bit or 64-bit view. I've tried using:
key.OpenSubKey(#"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
But it has the same outcome. Now if I just write without any view then my program successfully writes to the subkey:
SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon
Basically all I want is to write to the subkey:
SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Anyone know why the above code isn't writing to the requested key? (I will point out that AutoAdminLogon and the other two keys are used by the windows default credential provider such that when windows starts it checks those keys and if AutoAdminLogon is set to 1 then it logs in automatically with the given username and password. I'm doing this to allow a computer to be logged in as guest by setting the keys then rebooting the computer).
It's odd that I've been working on this for a day now and just realized I needed to do:
key = key.OpenSubKey(#"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
And then everything worked. I did not know that you had to do that. Thanks for everyone that responded. I was just messing around and searched for my key and noticed it was being placed in the wrong spot.