Solved

Delete from Menu

Posted on 2002-05-19
6
210 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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