Solved

Adding/Removing Items to/from Start Menu

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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