Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delete from Menu

Posted on 2002-05-19
6
Medium Priority
?
228 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
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!

 

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 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

705 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