Author: Jonas Bilinkevicius
How to delete a shortcut link
Answer:
1 2 procedure DeleteShortcut(const3 User {See scUserKey... codes},
4 Where {See scWhereKey... codes},
5 Name {Name for the shortcut link, w/o ".lnk"}: string);
6 var7 s: string;
8 begin9 s := GetEnvVar(scWinDirKey);
10 if User <> '' then11 s := s + '\Profiles\' + User
12 elseif OprSysPlatform = osWinNT then13 raise Exception.CreateFmt('Must have user name to delete shortcut (%s) for NT',
14 [Name]);
15 if Where = '' then16 raise Exception.CreateFmt('Where must be specified to delete shortcut (%s)',
17 [Name]);
18 ifnot DirectoryExists(s) then19 raise Exception.Create('User profile does not exist for ' + User);
20 s := s + '\' + Where;
21 DeleteFile(s + '\' + Name + '.lnk');
22 end;