Solved

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

Posted on 1998-08-14
10
236 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

772 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