Solved

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

Posted on 1998-08-14
10
230 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 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

20 Experts available now in Live!

Get 1:1 Help Now