Answered Need Help with Modify Registry Key

vmars316

Active member
Joined
Aug 24, 2020
Messages
39
Programming Experience
Beginner
Hello & Thanks ;
Win 10 , VS vb.net .vb
I am trying to to Modify
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TabbedBrowsing
value :ShortcutBehavior
from 2 to 1 .
Which will disable "Open Tab in New window" .
I am writing a KidSafeBrowser and I want to restrict opening a 'New Tab' .
Without Disabling this a new instance of IE 11 is opened , and kiddos can go anywhere .
Program checks every download page URL against a list of Safe-Sites .
Working with the Registry is new to me , so I am a bit 'gun shy' .
And I want to get it right the 1st time .
Anyways , here is my code below .
I think I am close but I need help to properly code this .
Thanks for your Help...
VB.NET:
 Dim rKey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Internet Explorer\TabbedBrowsing\ShortcutBehavior", True)
       Key.SetValue("ShortcutBehavior", 1, RegistryValueKind.DWord)
       key.Close()
 
Web browser control is based on settings from IE. I don't agree to changing the values of the registry of other programs, when their are a variety of other ways including events which can help with this.
Generally speaking, I would agree. If it's in a specific environment though, it's not necessarily a bad thing. If you're in a situation where only children are using the system and those children should only be using your browser and never IE directly then making changes that affect IE aren't necessarily a problem. If you're in a situation where other people use the same machine but use Edge or Firefox or Chrome then it still doesn't matter. That said, it is a good idea to understand exactly what the ramifications of doing so are.
Besides, isn't is generally considered bad practice now a days to be storing data in the registry, when we know %appdata% is more suitable. Editing the registry is also so old.
I would agree that it's not a good idea to store your own app's data and settings in the Registry but that's not what's happening here. This is a case of making use of data that another app is already storing in the Registry.

Having said all that, your idea of a whitelist of sites may well be the superior option regardless. That is, as long as the user can't just open an IE window and navigate elsewhere. It's actually much more complex to prevent that in a WebBrowser control than simply handling the NewWindow event. There are various specific ways that new windows can be opened and that only catches some of them.

Another point to consider is whether using IE via the WebBrowser control is a good idea in the first place. There is the WebView and WebView2 controls available that use the old and new Edge browsers and provide more control and a better interface nowadays, so they may be a better option.
 
It only webview 2 which is in WPF, and I do agree with you that this might be more suitable than what the OP is currently doing. It's webview which only belongs to Android if I recall.

Anyway, getting late now. 4AM - Time to hit the sack. Good night!
 
Back
Top