Solved

Adding/Removing Items to/from Start Menu

Posted on 1998-08-25
2
145 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

Industry Leaders: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

696 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