Solved

Adding/Removing Items to/from Start Menu

Posted on 1998-08-25
2
146 Views
Last Modified: 2010-04-04
How can I add/remove items to/from the StartUp section of the Start Menu. NOTE: This would have to work for both Windows 95 and Windows NT ?
0
Comment
Question by:j_mollaghan
[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
2 Comments
 
LVL 4

Accepted Solution

by:
BoRiS earned 50 total points
ID: 1337680
j_mollaghan

here is a code snippet I got from someone a while ago...

uses

  ShlObj, ActiveX, ComObj, Registry;



procedure TForm1.Button1Click(Sender: TObject);

var

  MyObject  : IUnknown;

  MySLink   : IShellLink;

  MyPFile   : IPersistFile;

  FileName  : String;

  Directory : String;

  WFileName : WideString;

  MyReg     : TRegIniFile;

begin

  MyObject := CreateComObject(CLSID_ShellLink);

  MySLink := MyObject as IShellLink;

  MyPFile := MyObject as IPersistFile;

  FileName := 'NOTEPAD.EXE';

  with MySLink do begin

    SetArguments('C:\AUTOEXEC.BAT');

    SetPath(PChar(FileName));

    SetWorkingDirectory(PChar(ExtractFilePath(FileName)));

  end;

  MyReg := TRegIniFile.Create(

    'Software\MicroSoft\Windows\CurrentVersion\Explorer');



// Use the next line of code to put the shortcut on your desktop

  Directory := MyReg.ReadString('Shell Folders','Desktop','');



// Use the next three lines to put the shortcut on your start menu

//  Directory := MyReg.ReadString('Shell Folders','Start Menu','')+

//      '\Whoa!';

//  CreateDir(Directory);



  WFileName := Directory+'\FooBar.lnk';

  MyPFile.Save(PWChar(WFileName),False);

  MyReg.Free;

end;



end.

hope this helps

Later
BoRiS
0
 

Author Comment

by:j_mollaghan
ID: 1337681
I figured it out myself. I used a slightly different approach (using SHGetSpecialFolderLocation to find the location of the StartUp folder within the Start Menu).
0

Featured Post

Technology Partners: 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!

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…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 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