Windows下在所有的文件添加右键菜单功能

Windows下在所有的文件添加右键菜单功能


如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033

目录

环境:
系统版本:windows 7 64bit


前言

我们有的程序在使用时需要先打开exe在执行相应文件,但是每次这么打开特别麻烦。如果能够添加右键菜单就方便多了。这里以Depends.exe为例介绍如何添加右键菜单功能。

1.注册表HKEY_CLASSES_ROOT - shell简介

HKEY_CLASSES_ROOT是应用程序运行时必需的信息,shell字键有个一”action“子键,如同”open“一样,这里有一个command子键;command子键有一个缺省句值,它包含了运行程序的命令行。将一个”open“子键放在一个对象类型的shell子键中会在这个对象类型的弹出菜单上多出一个”open“选项,给这个open子键一个command(缺省命令行"C:\Windows \Notepad.exe %1")子键会使得打开这个对象类型时使用笔记本做为缺省应用程序。其他操作选项包括View,Print,Copy,Virus,Scan等等。

下表给出了HKEY_CLASSES_ROOT的各个子项,可以在其下注册扩展处理程序。 请注意,许多扩展处理程序无法在所有列出的子项下注册。

子项描述可能的处理程序
*All filesShortcut Menu, Property Sheet, Verbs (see below)
AllFileSystemObjectsAll files and file foldersShortcut Menu, Property Sheet, Verbs
FolderAll foldersShortcut Menu, Property Sheet, Verbs
DirectoryFile foldersShortcut Menu, Property Sheet, Verbs
Directory\BackgroundFile folder backgroundShortcut Menu only
DesktopBackgroundDesktop background (Windows 7 and higher)Shortcut Menu, Verbs
DriveAll drives in MyComputer, such as “C:”Shortcut Menu, Property Sheet, Verbs
NetworkEntire network (under My Network Places)Shortcut Menu, Property Sheet, Verbs
Network\Type#All objects of type # (see below)Shortcut Menu, Property Sheet, Verbs
NetShareAll network sharesShortcut Menu, Property Sheet, Verbs
NetServerAll network serversShortcut Menu, Property Sheet, Verbs
network_provider_nameAll objects provided by network provider “network_provider_name”Shortcut Menu, Property Sheet, Verbs
PrintersAll printersShortcut Menu, Property Sheet
AudioCDAudio CD in CD driveVerbs only
DVDDVD drive (Windows 2000)Shortcut Menu, Property Sheet, Verbs

2.添加右键菜单功能注册表文件

将下列内容保存为*.reg。
注意:修改D:\Depends_cn\Depends.exe为需要程序的实际路径

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Depends]
@="Depends分析"

[HKEY_CLASSES_ROOT\*\shell\Depends\command]
@="\"D:\\Depends_cn\\Depends.exe\" \"%1\""

3.结果

在这里插入图片描述

4.其他

4.1 访问D:\Program被拒绝

在这里插入图片描述

参考:
https://zhidao.baidu.com/question/13504107.html
故障现象:
所有未知格式文件打开的时候,则跳出“该文件拒绝访问”;当点鼠标右键直接选“打开方式”的时候也会弹出“该文件拒绝访问”警告窗口;如果右方已经有部分程序列表,则在点右侧次级菜单中的“选择程序”时跳出“该文件拒绝访问”的警告.
故障诊断:
未知格式文件打开方式关联被恶意修改.
解决方法:
把下面的代码放到记事本中去,改名为*.reg 文件,双击它就会把信息写进注册表,之后就解决问题了!

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Unknown]
"AlwaysShowExt"=""
"QueryClassStore"=""

[HKEY_CLASSES_ROOT\Unknown\shell]
@="openas"

[HKEY_CLASSES_ROOT\Unknown\shell\openas]
[HKEY_CLASSES_ROOT\Unknown\shell\openas\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,25,00,53,\
00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,5c,00,73,00,\
79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,68,00,65,00,6c,00,6c,\
00,33,00,32,00,2e,00,64,00,6c,00,6c,00,2c,00,4f,00,70,00,65,00,6e,00,41,00,\
73,00,5f,00,52,00,75,00,6e,00,44,00,4c,00,4c,00,20,00,25,00,31,00,00,00

4.2 Dependency Walker 右键菜单管理

echo off
title Dependency Walker 右键菜单管理

:主菜单
color 1B
cls
echo.*-----------------------------------------------------------------------------*
echo * *************************** 安装/卸载右键菜单 *******************************
echo.*-----------------------------------------------------------------------------*
echo.*                                                                    *
echo.*         (1) 安装右键菜单                                                    *
echo.*                                                                    *
echo.*         (2) 卸载右键菜单                                                    *
echo.*                                                                    *
echo.*-----------------------------------------------------------------------------*
echo.* (A)安装  (U)卸载                                                   (X)退出  *
echo.*-----------------------------------------------------------------------------*
echo.*     请在管理员下运行...........               by Webenvoy (www.newasp.net)  *
echo *******************************************************************************
SET /P runcd=   请输入()中的数字键并按回车 :
if /I "%runcd%"=="1" goto Installation
if /I "%runcd%"=="2" goto Uninstallation
if /I "%runcd%"=="A" goto Installation
if /I "%runcd%"=="U" goto Uninstallation
if /I "%runcd%"=="X" goto EX
goto 主菜单

:EX
exit

:Installation
cls
color 1B
REG ADD "HKCR\dllfile\shell\Open with Dependency Walker" /v "" /t REG_SZ /d "用 Dependency Walker 打开" /f
REG ADD "HKCR\dllfile\shell\Open with Dependency Walker" /v "Icon" /t REG_SZ /d "%cd%\depends.exe" /f
REG ADD "HKCR\dllfile\shell\Open with Dependency Walker\command" /v "" /t REG_SZ /d "%cd%\depends.exe \"%%1\"" /f

REG ADD "HKCR\exefile\shell\Open with Dependency Walker" /v "" /t REG_SZ /d "用 Dependency Walker 打开" /f
REG ADD "HKCR\exefile\shell\Open with Dependency Walker" /v "Icon" /t REG_SZ /d "%cd%\depends.exe" /f
REG ADD "HKCR\exefile\shell\Open with Dependency Walker\command" /v "" /t REG_SZ /d "%cd%\depends.exe \"%%1\"" /f

echo ***************************************************************************
echo.
echo     右键菜单安装完成......
echo.
echo ***************************************************************************
pause
exit

:Uninstallation
cls
color 1B
REG DELETE "HKCR\dllfile\shell\Open with Dependency Walker" /f
REG DELETE "HKCR\exefile\shell\Open with Dependency Walker" /f
echo ***************************************************************************
echo.
echo     右键菜单卸载完成......
echo.
echo ***************************************************************************
pause
exit


Reference:

  1. https://docs.microsoft.com/zh-cn/windows/desktop/shell/reg-shell-exts
  2. https://baike.baidu.com/item/HKEY_CLASSES_ROOT/10759191

觉得文章对你有帮助,可以扫描二维码捐赠给博主,谢谢!
在这里插入图片描述
如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

itas109

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值