Browse Source

Merge 2c480b73bb into 5c172a3e49

pull/216/merge
lennylxx 10 years ago
parent
commit
8c410d3233
1 changed files with 42 additions and 2 deletions
  1. +42
    -2
      shadowsocks-csharp/View/MenuViewController.cs

+ 42
- 2
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using ZXing;
using ZXing.Common;
using ZXing.QrCode;
@@ -236,7 +237,7 @@ namespace Shadowsocks.View
void notifyIcon1_BalloonTipClicked(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(updateChecker.LatestVersionURL);
Process.Start(GetDefaultBrowserPath(), updateChecker.LatestVersionURL);
_notifyIcon.BalloonTipClicked -= notifyIcon1_BalloonTipClicked;
}
@@ -325,9 +326,48 @@ namespace Shadowsocks.View
}
}
private static string GetDefaultBrowserPath()
{
string userChoice = @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice";
string commandPath = @"$BROWSER$\shell\open\command";
string browserPath = null;
try
{
// Read default browser path from userChoice Key
RegistryKey userChoiceKey = Registry.CurrentUser.OpenSubKey(userChoice, false);
string progId = (userChoiceKey.GetValue("ProgId").ToString());
userChoiceKey.Close();
// Look up the path of the executable
commandPath = commandPath.Replace("$BROWSER$", progId);
RegistryKey pathKey = Registry.ClassesRoot.OpenSubKey(commandPath, false);
browserPath = pathKey.GetValue(null).ToString().ToLower().Replace("\"", "");
pathKey.Close();
// Trim parameters.
string exeSuffix = "exe";
if (!browserPath.EndsWith(exeSuffix))
{
browserPath = browserPath.Substring(0, browserPath.LastIndexOf(exeSuffix, StringComparison.Ordinal) + exeSuffix.Length);
}
}
catch (Exception e)
{
Logging.LogUsefulException(e);
}
if (browserPath == null)
{
browserPath = "iexplore.exe";
}
return browserPath;
}
private void AboutItem_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/shadowsocks/shadowsocks-csharp");
string aboutLink = "https://github.com/shadowsocks/shadowsocks-csharp";
Process.Start(GetDefaultBrowserPath(), aboutLink);
}
private void notifyIcon1_DoubleClick(object sender, MouseEventArgs e)


Loading…
Cancel
Save