Solved

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

Posted on 1998-08-14
10
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

631 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