Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
Add Path to Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
xfoxfu committed Jul 26, 2015
1 parent e1aeeee commit 3222ef2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Auth/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.19")]
[assembly: AssemblyFileVersion("1.2.0.19")]
[assembly: AssemblyVersion("1.3.0.7")]
[assembly: AssemblyFileVersion("1.3.0.7")]
25 changes: 13 additions & 12 deletions Installer/Install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,42 @@ private void Install_Load(object sender, EventArgs e)
this.dirBox.Text = AppDomain.CurrentDomain.BaseDirectory;
}

/// <summary>
/// 注册启动项到注册表
/// </summary>
public void RegURL(string name)
{
//注册的协议头,即在地址栏中的路径 如QQ的:tencent://xxxxx/xxx 我注册的是jun 在地址栏中输入:jun:// 就能打开本程序
var surekamKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(name);
//以下这些参数都是固定的,不需要更改,直接复制过去
var shellKey = surekamKey.CreateSubKey("shell");
var openKey = shellKey.CreateSubKey("open");
var commandKey = openKey.CreateSubKey("command");
surekamKey.SetValue("URL Protocol", "");
//这里可执行文件取当前程序全路径,可根据需要修改
var exePath = this.dirBox.Text + "URLSchemeHandler.exe";
commandKey.SetValue("", "\"" + exePath + "\"" + " \"%1\"");
}

/// <summary>
/// 取消注册
/// </summary>
public void UnRegURL(string name)
public void UnReg(string name)
{
//直接删除节点
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(name);
}

public void RegFilePos(string name)
{
var surekamKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(name);
var dirKey = surekamKey.CreateSubKey("dir");
var insPath = this.dirBox.Text;
dirKey.SetValue("", insPath);
var authPath = this.dirBox.Text + "auth.exe";
dirKey.SetValue("auth", authPath);
}

private void insButton_Click(object sender, EventArgs e)
{
RegURL("rapid");
RegFilePos("rapid");
System.Diagnostics.Process.Start(this.dirBox.Text + "conf.exe");
}

private void uninsButton_Click(object sender, EventArgs e)
{
UnRegURL("rapid");
UnReg("rapid");
}
}
}
4 changes: 2 additions & 2 deletions Installer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.18")]
[assembly: AssemblyFileVersion("1.0.0.18")]
[assembly: AssemblyVersion("1.1.0.6")]
[assembly: AssemblyFileVersion("1.1.0.6")]

0 comments on commit 3222ef2

Please sign in to comment.