Right button to go

Source: Internet
Author: User

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?!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.