Solved

How to add my menu item to the system menu of Win 95/NT ?

Posted on 1998-08-14
10
232 Views
Last Modified: 2010-04-04
After installed winzip, we can find menu item "Add to ZIP" when right click a file in the file explorer or in an open dialog ...

Can I register my own menu item and procedure to the system menu like that?
0
Comment
Question by:yysun
  • 7
  • 3
10 Comments
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
ID: 1362076
yysun

here is a code snippet from the delphi tips and tricks...

In Win32, create a new registry entry under the
                          HKEY_CLASSES_ROOT root key that points to the file
                          extension, the command line to invoke, and the icon to
                          display. Under Win16, simply file extension and the command
                          line to invoke in the [Extensions] sections of Win.ini.

                          Example:

                          uses
                            Registry, {For Win32}
                            IniFiles; {For Win16}

                          {For Win32}
                          procedure TForm1.Button1Click(Sender: TObject);
                          var
                            reg: TRegistry;
                          begin
                            reg := TRegistry.Create;
                            reg.RootKey := HKEY_CLASSES_ROOT;
                            reg.LazyWrite := false;
                           {Add Program Support}
                            reg.OpenKey('.bor\shell\open\command',
                                        true);
                          {Invoke the program passing the file name as the first parameter}
                            reg.WriteString('',
                                           'C:\Program Files\Borland\Delphi 3\Project1.exe %1');
                           {Add Icon Display}
                            reg.CloseKey;
                            reg.OpenKey('.bor\DefaultIcon',
                                        true);
                          {Use the first icon in the executable to display}
                            reg.WriteString('',
                                            'C:\Program Files\Borland\Delphi 3\Project1.exe,0');
                            reg.CloseKey;
                            reg.free;
                          end;

                          {For Win16}
                          procedure TForm1.Button2Click(Sender: TObject);
                          var
                            WinIni : TIniFile;
                            WinIniFileName : array[0..MAX_PATH] of char;
                            s : array[0..64] of char;
                          begin
                            GetWindowsDirectory(WinIniFileName, sizeof(WinIniFileName));
                            StrCat(WinIniFileName, '\win.ini');
                            WinIni := TIniFile.Create(WinIniFileName);
                            WinIni.WriteString('Extensions',
                                         'bor',
                                         'C:\PROGRA~1\BORLAND\DELPHI~1\PROJECT1.EXE ^.bor');
                            WinIni.Free;
                            StrCopy(S, 'Extensions');
                            SendMessage(HWND_BROADCAST, WM_WININICHANGE,
                                 0, LongInt(@S));
                          end;

Later
BoRiS
0
 

Author Comment

by:yysun
ID: 1362077
BoRiS:
Thank you very much for your help.
Would you also please give me the URL of "the delphi tips and tricks". It sounds a good place to find more code snippets there.
0
 

Author Comment

by:yysun
ID: 1362078
BoRiS:
I'm sorry, after try the code you gave me, I found it cannot solve my problem.
What I want is not only to make an association between a file extension with my program. I want add my menu item into the menu of Win95's system menu and call procedure in my EXE or DLL just WinZip did.
I'm looking forward to get more help.
0
 

Author Comment

by:yysun
ID: 1362079
BoRiS:
I'm sorry, after try the code you gave me, I found it cannot solve my problem.
What I want is not only to make an association between a file extension with my program. I want add my menu item into the menu of Win95's system menu and call procedure in my EXE or DLL just WinZip did.
I'm looking forward to get more help.
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1362080
yysum

I'll check it and get right back to you as sson as I figured it out...did it once just got to remember how...

the url for the delphi thngie is:

http://www.inprise.com/devsupport/delphi/qanda/

Later
BoRiS
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:yysun
ID: 1362081
BoRiS:
I'm sorry, after try the code you gave me, I found it cannot solve my problem.
What I want is not only to make an association between a file extension with my program. I want add my menu item into the menu of Win95's system menu and call procedure in my EXE or DLL just WinZip did.
I'm looking forward to get more help.
0
 

Author Comment

by:yysun
ID: 1362082
BoRiS:

I'm sorry to send the same for several times by wrong.
Waiting for your help. Cheers!
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1362083
yysun

add this to the code I gave you after the .bor stuff (after reg.closekey;)

                                reg.OpenKey('\txtfile\shell\hello',
                                            true);
                        reg.WriteString('', 'say hello');
                        
                        reg.OpenKey('\txtfile\shell\hello\command',
                                            true);
                        reg.WriteString('',
                                               'C:\Windows\notepad.exe %1');
                        reg.CloseKey;

this will add a menu item to the popup menu called say hello when you right click on a text file and then when you click on say hello it will open notepad...

just replace what you have to with your names and program names etc...

Later
BoRiS
0
 

Author Comment

by:yysun
ID: 1362084
BoRiS:

Thank you again.I think this answer is worth of 100 points.
0
 

Author Comment

by:yysun
ID: 1362085
BoRiS:

Are you still there?

The second sample assigns the "Say hello" to .txt file.
How to assign this menu to all typies of files and even several selected file via Shift+right click?

yysun
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 107
How to debug For loops? 3 46
DBGrid or StringGrid ? 6 71
PHP preg_replace code convert to Delphi 14 35
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now