Solved

Delete from Menu

Posted on 2002-05-19
6
215 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
[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
  • 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
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!

 

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

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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