惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - Findekano

C#异步调用的bug? 恩,VS调试时候的监视也不能够尽信啊 最近正在看的几本书 VS.NET2005使用体验(二) [C# FAQ]通过Windows Forms预处理Win32消息 VS.NET2005使用体验(一) OpenGL & MFC 相关联接 .::Findekano's Tidbet:: .::Findekano's Tidbet:: .::Findekano's Tidbet:: .:: Findekano's Tidbet :: CorelDraw's Application Recovery Manager.. .:: Findekano's Tidbet :: C#&.NET Framework中的Beep .:: Findekano's Tidbet :: [C# FAQ]C#代码中如何启动另一个应用程序或批处理程序? 今天开始,努力攒钱... 又闻到味道 如何保持代码格式?
将应用程序直接加入到"Run..."中打开的小工具
Findekano · 2004-11-07 · via 博客园 - Findekano

      一直以来很习惯用Win+R打开"Run..."对话框,然后输入命令来打开要使用的程序,如winword,如wmplayer....
然而很多程序安装好之后并不能在Run...中简单输入程序名来打开,于是原来一直手动编辑注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
将新安装的项添加进去。近日重装了系统,原来加好的列表全没了-_-||,一个一个的重新手动加又嫌麻烦,所以干脆写个小工具,能够把选定的可执行文件快速加入到app Paths列表中。
     要做的很简单。首先修改注册表,在HKEY_CLASSES_ROOT\exefile\shell下加一个新项"Add2Cmd",默认值为“加入到命令列表...",在其下再创建一个名为"command"的项,其默认值为"C:\Document\Visual Studio Projects\Add2Cmd\Add2Cmd\bin\Debug\Add2Cmd.exe" "%1",其中C:\Document\Visual Studio Projects\Add2Cmd\Add2Cmd\bin\Debug\Add2Cmd.exe是我写的程序的地址。%1作为参数即为被选定的可执行文件的绝对路径和文件名。
    执行Add2Cmd.exe的时候将被选定的可执行文件的绝对路径和文件名记入HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths即可。
代码如下所示:

static void Main(string[] args) 
        
{
            
using (RegistryKey
                       Software 
= Registry.ClassesRoot.OpenSubKey(@"exefile\shell",true),
                       shell 
= Software.CreateSubKey("add2cmd"),
                       command 
= shell.CreateSubKey("command"))
            
{
                shell.SetValue(
"""添加到命令列表");    // 修改(默认)项的值
                command.SetValue("""\"" + Application.ExecutablePath + "\" \"%1\"");    // 修改路径
            }


            
if( args.Length > 1 )
                MessageBox.Show(
"参数过多,程序没有正常执行。","错误",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);
            
else if( args.Length == 1 )
            
{
                
string appPathName = args[0];
                
int index = appPathName.LastIndexOf("\\");
                
string appName = appPathName.Substring(index+1);
                
string appPath = appPathName.Substring(0,index);

                
using (RegistryKey
                           Software 
= Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths",true),
                           newCmd 
= Software.CreateSubKey(appName))
                
{
                    newCmd.SetValue(
"Path", appPath);    // 修改路径
                    newCmd.SetValue("", appPathName);    // 修改(默认)项的值
                }


                MessageBox.Show(
"成功加入到命令列表,可以在Start->Run中输入"+appName+"运行该程序了。","成功",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Information);
            }

        }