Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1998-08-14
10
Medium Priority
?
246 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 400 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

722 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