|
-
Jul 29th, 2007, 09:55 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Help with opening Link
hi guys help please. Currently, I have this code
Code:
System.Diagnostics.Process.Start(EventAttachmentLink);
to open a link, but it opens the link in one of my opened Internet Browser. My question is, is it posible to open a particular link in a new Internet Browser Window? Thanks in advance!
-
Jul 29th, 2007, 10:45 PM
#2
Re: Help with opening Link
That is a function of the browser itself. The browser will normally have an option to change that default behaviour. If you want to override the default behaviour without adjusting the browser settings then you need to specify the browser itself as the file name and the URL as an argument, e.g.
C# Code:
Process.Start("iexplore", EventAttachmentLink);
The problem with that is that you won't be using the default browser in many cases. I believe that Windows stores information about browsers and which one is the default in the registry, so you could get the correct path from there.
I'm fairly sure that Shaggy Hiker or kleinma tackled this issue some time ago and put something in the Codebank too. I don't remember the specifics though. It was probably the VB.NET Codebank but conversion would be simple.
-
Jul 30th, 2007, 01:54 AM
#3
Thread Starter
Fanatic Member
Re: Help with opening Link
OK..I'll give it a try..Thanks again JM.
-
Jul 31st, 2007, 12:15 AM
#4
Thread Starter
Fanatic Member
Re: Help with opening Link
Ok..I come up with the code below.
Code:
//Get path of the default internet explorer
string defaultBrowser = null;
//HKEY_CLASSES_ROOT\https\shell\open\command is the Registry path where you can get the default Internet Explorer
RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command");
if (regKey != null)
{
//The value name in my registry is blank ("") or (default)
//but it contains value "C:\Program Files\Internet Explorer\iexplore.exe" -nohome
defaultBrowser = (string)regKey.GetValue("");
//Since I only need the path (C:\Program Files\Internet Explorer\iexplore.exe)
//I will remove any charcater before the first '"'
defaultBrowser = defaultBrowser.Remove(0, defaultBrowser.IndexOf("\"") + 1);
//And remove any character after the second '"'
defaultBrowser = defaultBrowser.Remove(defaultBrowser.IndexOf("\""));
//Remove any white space character
defaultBrowser.Trim();
}
//Open Link
System.Diagnostics.Process pOpenLink = new System.Diagnostics.Process();
pOpenLink.StartInfo.CreateNoWindow = true;
pOpenLink.StartInfo.FileName = defaultBrowser;
pOpenLink.StartInfo.Arguments = EventAttachmentLink;
pOpenLink.Start();
Thanks a lot JM!
Last edited by daimous; Jul 31st, 2007 at 12:20 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|