Solved

Adding/Removing Items to/from Start Menu

Posted on 1998-08-25
2
141 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
2 Comments
 
LVL 4

Accepted Solution

by:
BoRiS earned 50 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

14 Experts available now in Live!

Get 1:1 Help Now