There are many languages used to develop Windows programs, generally speaking, a small general-purpose program with Delphi is a good choice, have not heard of it??? The clever programmer uses Delphi. We use the internet commonly used foxmail, network ants are developed with it.
The interest came to use Delphi to do a small program, such as: "Large file cutting machine", to share with friends, want to register it to the system's right key? Friends just click on the file Right button, you can choose to start your masterpiece to work.
Now let's show you how to invoke the right button:
procedure TForm1.Button1Click(Sender: TObject);
var
a:TRegistry;
begin
a:=TRegistry.create;
a.rootkey:=HKEY_CLASSES_ROOT;
//用openkey打开一个主键,如果此主键不存在则自动创建
if a.openkey(*\shell\cutbig,true) then
begin
//用writestring将设置值写入打开的主键
a.writestring(,切割与组装(&k));
a.closekey;
end;
if a.openkey(*\shell\cutbig\command,true) then
begin
//command子键的内容是点击右键后选择相应项后要运行的程序;
//%1是在单击右键时选中的文件名
a.writestring(,c:\delphi\myprogram.exe+"%1");
a.closekey;
end;
a.free;
end;
Of course, remember to add the registry unit in the interface uses, otherwise the tregistry will not be recognized at compile time, which is provided by Delphi for processing the registry.
If you need to delete this function of the right button, how do you do it? Very simple:
procedure TForm1.Button2Click(Sender: TObject);
var
a:TRegistry;
begin
a:=TRegistry.create;
a.rootkey:=HKEY_CLASSES_ROOT;
//用deletekey删除一个主键,其所包含的子键也被删除,如果已无此主键,运行删除操作不会带来别的危害
a.deletekey(*\shell\cutbig);
a.free;
end;
How about, right button to call to come, the feeling that goes, is cool?!