Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
Member Area
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Become a Member
-Why sign up!
-Chat Online!
-Indexes NEW!!
-Build your resume
-Find a job
-Post a job
-Resume Search
-Link to us
Visit Embarcadero
Embarcadero Community
How do I add some items to Explorer's right-click menu Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Add items to the Windows Explorer right-click menu 29-Sep-02
Delphi 6.x
User Rating
No Votes
# Votes
DSP, Administrator
Reference URL:
			Author: William Gerbert 

How do I add some items to Explorer's right-click menu, which appears when the user 
right-clicks on a certain file type?


1   procedure add_context_menu;
2   type
3     extns = (wav, png, bmp, jpg);
4   const
5     ext_names: array[extns] of string = ('.wav', '.png', '.bmp', '.jpg');
6   var
7     ext: extns;
8     reg: TRegistry;
9     name: string;
10    command: string;
11  begin
12    reg := TRegistry.Create;
13    reg.RootKey := HKEY_CLASSES_ROOT;
14    {Build the command string we want to store}
15    command := '"' + Application.ExeName + '" "%1"';
16    {Loop over extensions we can handle}
17    for ext := wav to jpg do
18    begin
19      {See if this extension is already known in HKEY_CLASSES_ROOT}
20      if reg.OpenKeyReadOnly('\' + ext_names[ext]) then
21      begin
22        name := reg.ReadString(''); {Get the name of this type}
23        if name <> '' then
24          {If not blank, open this type's shell key, but don't create it}
25          if reg.OpenKey('\' + name + '\shell', False) then
26            {Try to create a new key called "APTprocess". Note that for Delphi5 we
27            need to set the access explicitly}
28            reg.Access := KEY_READ or KEY_WRITE;
29        if reg.OpenKey('APTprocess', True) then
30        begin
31          {The default value will be displayed in the context menu}
32          reg.WriteString('', '&APT process');
33          {So now open the command key, creating it if required}
34          reg.Access := KEY_READ or KEY_WRITE;
35          if reg.OpenKey('command', True) then
36            {and write the command string as the default value}
37            reg.WriteString('', command);
38        end;
39      end;
40    end;
41    reg.Free;
42  end;

Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10


Share this page
Download from Google

Copyright © Mendozi Enterprises LLC