怎么将程序添加到右键菜单中,并能向程序传递路径,程序能够提取
如何将程序添加到右键菜单中,并能向程序传递路径,程序能够提取
在网上搜到这些东西,不知道下面提到的%1代表什么,ParamStr(1) 函数在什么地方什么时候使用
问题如下:
1.如何将程序添加到右键菜单中。
2.如何使用加入菜单的程序打开(操作)选中的文件(文件夹),文件名参数的传递。
3.我的目的是按右键后选择该程序,后直接计算文件的内容,如同winrar一样。
4.希望给出个简短的例子。
谢谢大家
怎么?这个问题很难么???
--------------------------------------------
关于多种环境注册右键弹出事件的方法,请按照以下对应关系:\HKEY_CLASSES_ROOT\Folder\Shell 任意文件夹
\HKEY_CLASSES_ROOT\Directory\Shell 任意目录
\HKEY_CLASSES_ROOT\Drive\Shell 任意驱动器
\HKEY_CLASSES_ROOT\*\Shell 任意文件
新建一个主键,并在主键下添加一个特定主键(command),修改command的键值指到你的应用程序。例如:
建立\HKEY_CLASSES_ROOT\Folder\Shell\AimTest,将在Folder上按下右键时出现"AimTest"菜单
建立\HKEY_CLASSES_ROOT\Folder\Shell\AimTest,并设定该主键的缺省值为"我的测试菜单",则将在Folder上按下右键时出现"我的测试菜单"菜单钮。
建立\HKEY_CLASSES_ROOT\Folder\Shell\AimTest\command,并设定command"缺省"键值为"c:\tools\pse.exe" "%1",则将以Folder名为第一参数启动pse.exe。
* 注意command键值的双引号不可缺省另外:\HKEY_CLASSES_ROOT\Folder\Shellex
\HKEY_CLASSES_ROOT\Directory\Shellex\HKEY_CLASSES_ROOT\Drive\Shellex
\HKEY_CLASSES_ROOT\*\Shellex可以按应用程序在Registroy中的注册ID调用。这样可以调用.DLL和钩子函数。
但建议按第一种方法调用应用程序,因为注册一个ID实在麻烦。如果你的应用程序支持DDE,你可以参考
\HKEY_CLASSES_ROOT\Directory\Shell\Find键的设定来进行DDE设置。
来源于葵花宝典
--------------------------------------------
Uses Registry
var
reg:TRegistry;
begin
reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_CLASSES_ROOT;
Reg.CreateKey('\txtfile\shell\用我的记事本打开(&C)\command');
If Reg.OpenKey('txtfile\shell\用我的记事本打开(&C)\command', true) then
Reg.WriteString('',Extractfilepath(Application.ExeName)+Extractfilename(Application.ExeName)+' "%1"');
finally
Reg.Free;
end;
--------------------------------------------
var
Reg:TRegistry;
Key1,Key2:String;
begin
Reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_CLASSES_ROOT;
Key1:='\icofile\Shell\用 PicView 浏览';
Key2:='\Jpegfile\Shell\用 PicView 浏览';
if Add_Del then //add_del 是说是否向注册表中添加信息的意思,
begin{Add}
Reg.OpenKey(Key1+'\Command',True);
Reg.WriteString('',Application.ExeName+' "%1"');//写上程序的地址
Reg.OpenKey(Key2+'\Command',True);
Reg.WriteString('',Application.ExeName+' "%1"');
end else
begin{Delete} //去掉文件关联
Reg.OpenKey(Key1+'\Command',True);
Reg.DeleteKey(Key1);
Reg.OpenKey(Key2+'\Command',True);
Reg.DeleteKey(Key2);
end;
Reg.CloseKey;
finally
Reg.Free;
end;
http://www.hongen.com/pc/pcketang/jiqiao/win98zcb/zhuce013.htm
http://tech.sina.com.cn/c/2002-01-16/8472.html
--------------------------------------------
在网上搜到这些东西,不知道下面提到的%1代表什么,ParamStr(1) 函数在什么地方什么时候使用
问题如下:
1.如何将程序添加到右键菜单中。
2.如何使用加入菜单的程序打开(操作)选中的文件(文件夹),文件名参数的传递。
3.我的目的是按右键后选择该程序,后直接计算文件的内容,如同winrar一样。
4.希望给出个简短的例子。
谢谢大家
怎么?这个问题很难么???
--------------------------------------------
关于多种环境注册右键弹出事件的方法,请按照以下对应关系:\HKEY_CLASSES_ROOT\Folder\Shell 任意文件夹
\HKEY_CLASSES_ROOT\Directory\Shell 任意目录
\HKEY_CLASSES_ROOT\Drive\Shell 任意驱动器
\HKEY_CLASSES_ROOT\*\Shell 任意文件
新建一个主键,并在主键下添加一个特定主键(command),修改command的键值指到你的应用程序。例如:
建立\HKEY_CLASSES_ROOT\Folder\Shell\AimTest,将在Folder上按下右键时出现"AimTest"菜单
建立\HKEY_CLASSES_ROOT\Folder\Shell\AimTest,并设定该主键的缺省值为"我的测试菜单",则将在Folder上按下右键时出现"我的测试菜单"菜单钮。
建立\HKEY_CLASSES_ROOT\Folder\Shell\AimTest\command,并设定command"缺省"键值为"c:\tools\pse.exe" "%1",则将以Folder名为第一参数启动pse.exe。
* 注意command键值的双引号不可缺省另外:\HKEY_CLASSES_ROOT\Folder\Shellex
\HKEY_CLASSES_ROOT\Directory\Shellex\HKEY_CLASSES_ROOT\Drive\Shellex
\HKEY_CLASSES_ROOT\*\Shellex可以按应用程序在Registroy中的注册ID调用。这样可以调用.DLL和钩子函数。
但建议按第一种方法调用应用程序,因为注册一个ID实在麻烦。如果你的应用程序支持DDE,你可以参考
\HKEY_CLASSES_ROOT\Directory\Shell\Find键的设定来进行DDE设置。
来源于葵花宝典
--------------------------------------------
Uses Registry
var
reg:TRegistry;
begin
reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_CLASSES_ROOT;
Reg.CreateKey('\txtfile\shell\用我的记事本打开(&C)\command');
If Reg.OpenKey('txtfile\shell\用我的记事本打开(&C)\command', true) then
Reg.WriteString('',Extractfilepath(Application.ExeName)+Extractfilename(Application.ExeName)+' "%1"');
finally
Reg.Free;
end;
--------------------------------------------
var
Reg:TRegistry;
Key1,Key2:String;
begin
Reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_CLASSES_ROOT;
Key1:='\icofile\Shell\用 PicView 浏览';
Key2:='\Jpegfile\Shell\用 PicView 浏览';
if Add_Del then //add_del 是说是否向注册表中添加信息的意思,
begin{Add}
Reg.OpenKey(Key1+'\Command',True);
Reg.WriteString('',Application.ExeName+' "%1"');//写上程序的地址
Reg.OpenKey(Key2+'\Command',True);
Reg.WriteString('',Application.ExeName+' "%1"');
end else
begin{Delete} //去掉文件关联
Reg.OpenKey(Key1+'\Command',True);
Reg.DeleteKey(Key1);
Reg.OpenKey(Key2+'\Command',True);
Reg.DeleteKey(Key2);
end;
Reg.CloseKey;
finally
Reg.Free;
end;
http://www.hongen.com/pc/pcketang/jiqiao/win98zcb/zhuce013.htm
http://tech.sina.com.cn/c/2002-01-16/8472.html
--------------------------------------------