Solved

Delete from Menu

Posted on 2002-05-19
6
209 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

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

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…
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…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

22 Experts available now in Live!

Get 1:1 Help Now