Solved

Delete from Menu

Posted on 2002-05-19
6
212 Views
Last Modified: 2010-04-04
ok so you understand my question....

when i press the START button the main windows menu appears then i highlight PROGRAMS and another menu appears
Now on this menu there are many items...

I want some code to delete one of these items
example Phonebook

thanks in advance Dinkleburger
0
Comment
Question by:Dinkleburger
  • 4
  • 2
6 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 7019951
this should work as "TheShortcut" is just a .lnk file you can find its path via registry etc and call deletefile() on it.

procedure RemoveShortcuts;
var
  Directory: string;
  MyReg,
  QL_Reg   : TRegIniFile;
begin
  MyReg := TRegIniFile.Create('Software\MicroSoft\Windows\CurrentVersion\Explorer');
  try
    Directory := MyReg.ReadString('Shell Folders','Desktop', '');
    if Directory <> '' then
      DeleteFile(Directory + '\TheShortcut.lnk');

    Directory := MyReg.ReadString('Shell Folders','Start Menu', '');
    if Directory <> '' then
      DeleteFile(Directory + '\TheShortcut.lnk');

    Directory := MyReg.ReadString('Shell Folders','SendTo', '');
    if Directory <> '' then
      DeleteFile(Directory + '\TheShortcut.lnk');

    QL_Reg := TRegIniFile.Create('Software\MicroSoft\Windows\CurrentVersion\GrpConv');
    try
      Directory := QL_Reg.ReadString('MapGroups', 'Quick Launch', '');
      if Directory <> '' then
        DeleteFile(Directory + '\TheShortcut.lnk');
    finally
      QL_Reg.Free;
    end;
  finally
    MyReg.Free;
  end;
end;
0
 

Author Comment

by:Dinkleburger
ID: 7021092
Hello Inthe

the code compiles ok
but the Phonebook shortcut is still there?
Thanks
0
 
LVL 17

Expert Comment

by:inthe
ID: 7021115
hi,
im guessing you did replace "TheShortcut.lnk" with "PhoneBook.lnk" or whatever the phonebook name is?

if so what is the exact text of the shortcut?
(just so i can make one and test on)
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:Dinkleburger
ID: 7022923
Hello Inthe

yep i replaced the ShortcutLink with DTL DUST.lnk
that is the name of the Shortcut i want to delete

I looked through the registry... i dont know if this will help But when i added the shortcut i did not write anything to the registry...

it was added with some other command from Shell???
and then it appeared and worked...

Thanks agaian DB







0
 
LVL 17

Expert Comment

by:inthe
ID: 7023328
hi,
this should make life easier:

uses shlobj;

procedure TForm1.Button1Click(Sender: TObject);
Var
 SFolder :  pItemIDList;
 SpecialPath : Array[0..MAX_PATH] Of Char;
FILENAMETODELETE, filename : string;
 begin
 //note filename may be inside another folder
 //ie "Accessories" or "Borland" etc..
filename := 'GExperts\GExperts Readme.lnk';
SHGetSpecialFolderLocation(Form1.Handle, CSIDL_COMMON_PROGRAMS, SFolder);
SHGetPathFromIDList(SFolder, SpecialPath);
FILENAMETODELETE := strpas(Specialpath)+'\'+ filename;
DeleteFile(strpas(Specialpath)+'\'+ filename);
end;

CSIDL_COMMON_PROGRAMS will give like:

C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Visual C++ 6.0

whereas
CSIDL_PROGRAMS will give like:
C:\Documents and Settings\LoggedOnUserName\Start Menu\Programs\Microsoft Visual C++ 6.0

this depends on systems etc..

note also with shlobj's CSIDL_ consts,you can use them for the startmenu desktop etc also..ie
CSIDL_STARTUP  CSIDL_COMMON_STARTUP  


Regards Barry
0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 7023333
ps,
can delete the line:
FILENAMETODELETE := strpas(Specialpath)+'\'+ filename;
and the var FILENAMETODELETE ,i was testing and it wasnt working but i had forgot to add the  /  :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb download file link ? 1 132
Dev Express grid collapse 2 44
Convert MS Word document to a PDF file 9 78
Multi-layered image in FireMonkey 9 34
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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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