Windows Explorer中对所选文件增加右键菜单并关联自己程序的例子
2011-05-26 18:01
966 查看
为选中文件注册右键菜单
private void registerFile()
{ if (this.txtName.Text.Length == 0) return; // 注册到文件 //if (this.ckRegToFile.Checked) //{ RegistryKey shell = Registry.ClassesRoot.OpenSubKey("*", true).OpenSubKey("shell", true); if (shell == null) { shell = Registry.ClassesRoot.OpenSubKey("*", true).CreateSubKey("shell"); } RegistryKey custome = shell.CreateSubKey(this.txtName.Text); RegistryKey cmd = custome.CreateSubKey("command"); //下边为你想关联的程序可以是任何语言写的任何程序
//D:\Projects\ContextMenu\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe string executePath = @txtAppPath.Text; //Application.ExecutablePath
//%1 代表所选文件全路径 如c:\abcd.pdf
cmd.SetValue("", executePath + " %1"); cmd.Close(); custome.Close(); shell.Close(); MessageBox.Show("Register sucessfully!", "Notification"); //} }
private void registerFile()
{ if (this.txtName.Text.Length == 0) return; // 注册到文件 //if (this.ckRegToFile.Checked) //{ RegistryKey shell = Registry.ClassesRoot.OpenSubKey("*", true).OpenSubKey("shell", true); if (shell == null) { shell = Registry.ClassesRoot.OpenSubKey("*", true).CreateSubKey("shell"); } RegistryKey custome = shell.CreateSubKey(this.txtName.Text); RegistryKey cmd = custome.CreateSubKey("command"); //下边为你想关联的程序可以是任何语言写的任何程序
//D:\Projects\ContextMenu\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe string executePath = @txtAppPath.Text; //Application.ExecutablePath
//%1 代表所选文件全路径 如c:\abcd.pdf
cmd.SetValue("", executePath + " %1"); cmd.Close(); custome.Close(); shell.Close(); MessageBox.Show("Register sucessfully!", "Notification"); //} }
相关文章推荐
- 如何用程序实现增加二级windows文件右键菜单
- C#、VB.NET将自己的程序注册到系统的右键菜单(所有文件和目录)
- 添加IE右键菜单 以 调用和运行 自己的程序或文件
- 添加IE右键菜单 以 调用和运行 自己的程序或文件
- 改注册表实现的增加右键菜单右键菜单,注册自己的文件格式
- 在windows右键菜单中加入自己的程序 [转载]
- ubuntu 中增加鼠标右键菜单,为Windows 的exe 程序快速增加桌面快捷键
- 在windows系统的文件右键菜单中增加“命令提示符”
- 在windows右键菜单中加入自己的程序
- windows把任意程序加载到右键菜单的方法
- windows 上让文件类型和程序关联的批处理程序。
- windows7 我的电脑右键-管理“该文件没有与之关联的程序来执行该操作"
- (C#)Windows Shell 外壳编程系列7 - ContextMenu 注册文件右键菜单
- Windows Store apps开发[75]Windows 8 开发31日-第18日-文件关联和程序合约
- (C#)Windows Shell 外壳编程系列7 - ContextMenu 注册文件右键菜单
- windows8.1 explorer.exe win+E 出现“该文件没有与之关联的程序…………”解决办法
- (C#)Windows Shell 外壳编程系列7 - ContextMenu 注册文件右键菜单
- windows7 我的电脑右键-管理“该文件没有与之关联的程序来执行该操作"(搜集整理)
- Windows下.py文件右键菜单的增删
- win 7 我的电脑右键-管理“该文件没有与之关联的程序来执行该操作