473,414 Members | 1,928 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

WebBrowser as default

32
I created a webrowser in VB.net to track employee usage and it seems to be working fine but I wanted to find out what it would take to set this as a default browser on a PC. I also would need to know how to pull the URL from shortcuts so when the program opens I can have it open to the URL in the shortcut.

thank you
John Young
Mar 9 '09 #1
7 2714
tlhintoq
3,525 Expert 2GB
Here's what I do in C#. As you can see, the default browser is specified in the registry. You should be able to translate this to VB fairly easily.

Expand|Select|Wrap|Line Numbers
  1.  
  2.         private void pbLogo_Click(object sender, EventArgs e)
  3.         {
  4.             OpenURL(@"http://gallery.me.com/tlhintoq");
  5.         }
  6.  
  7.  
  8.  
  9.         private static string GetDefaultBrowserPath()
  10.         {
  11.             string key = @"http\shell\open\command";
  12.             Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(key, false);
  13.             // get default browser path
  14.             return StringToPath(((string)registryKey.GetValue(null, null)));
  15.         }
  16.  
  17.  
  18.  
  19.         void OpenURL(string TheURL)
  20.         {
  21.             string defaultBrowserPath = GetDefaultBrowserPath();
  22.  
  23.             try
  24.             {
  25.                 // launch default browser
  26.                 System.Diagnostics.Process.Start(defaultBrowserPath, TheURL);
  27.             }
  28.             catch (Exception exp)
  29.             {
  30.                 MessageBox.Show(exp.Message);
  31.             }
  32.         }
Mar 9 '09 #2
jyoung2
32
What I am trying to do is set the webbrowser I created to the default browser. I am not looking for the current default I am trying to change it.
Mar 9 '09 #3
tlhintoq
3,525 Expert 2GB
If you know where that value is stored, you can write in a new value. Hence, change it.

Write a new value that contains the path to your custom browser.
Mar 9 '09 #4
jyoung2
32
I found where to change it, It is getting an error because it is not handeling URI Formats "System.ArgumentException: URI formats are not supported." So i am going to work though and see if I can work around this. If you have an idea of where to start that would be great, otherwise I will fight through it until I can form a coherent question, ;-) and try again. thanks!
Mar 9 '09 #5
tlhintoq
3,525 Expert 2GB
@jyoung2
Breakpoints are your friend. Set a breakpoint so you can see exactly what is being sent to the OpenURL method.

If I recall, you can send literals to the method if you put quotes around the entire string. If you don't use quotes then you have to translate characters such as spaces to %20 and so on.
Mar 9 '09 #6
jyoung2
32
My Current Hiccup is that i only recive the error when I open a link when my program is closed and when it opens the program it skips the break points. I am unsure how to get the program to open in debug mode. I am trying to figure out the information that is getting sent the program when it is opening so I can handle it.
In the debug folder is there a file that will open in debug mode when opened from outside of Visual Studio?
Mar 9 '09 #7
tlhintoq
3,525 Expert 2GB
Can't say as I've ever tried it.
I would have expected that if you already had it running in debug mode from Visual Studio, and your registry entry was pointing at the debug version of the application (the one in the debug folder) that it would pass it to the instance already open. But as I said, I've never tried it.
Mar 10 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matthias Huening | last post by:
Hi, os.startfile('http://www.python.org') works fine on WinXP with IE as default webbrowser. With Mozilla Firefox 0.9 as default webbrowser, however, I get an error. Firefox starts, the page...
1
by: JerryShea | last post by:
Hi, I am opening a word document (RTF) in a webbrowser control and automating it. Most automation features seem to work but when I execute: wordApp.ActiveDocument.PrintPreview() I get an...
0
by: Jim Hubbard | last post by:
How would I implement the IDispatch interface to handle the following in VB.Net <BEGIN> Controlling Download and Execution The WebBrowser Control gives you control over what it downloads,...
5
by: SPE - Stani's Python Editor | last post by:
Hi, During optimizing SPE for Ubuntu, I found something strange. I have Ubuntu 5.10 "The Breezy Badger" and unfortunately this code is not working: >>> import webbrowser >>>...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
8
by: Dustan | last post by:
At http://docs.python.org/whatsnew/modules.html on the webbrowser module, it says "A number of additional browsers were added to the supported list such as Firefox, Opera, Konqueror, and elinks." ...
11
by: Anil Gupte | last post by:
....and how do I insert one into my form? I used in VB 6.0 last, but cannot figure out where it is in .Net Thanx, -- Anil Gupte www.keeninc.net www.icinema.com
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: Gregory Bloom | last post by:
I'm running Python 2.5 under Windows. If I fire up IDLE and enter: it works like a champ, opening the page in Firefox. Same thing goes from a Windows cmd shell: it works as advertised. But...
14
by: Ron Adam | last post by:
Is anyone else having problems with the webbrowser module? Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) on linux2 Type "help", "copyright", "credits" or "license" for more...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.