Hello,
I'm trying to remove a shortcut from the start menu with the routine below.
It fails with I/O error 32 on the RmDir
IconText = the shortcut name
Destination=GetSpecialFolderLocation(ftPrograms)+'\SomeGroupName\'
WithDirectories specifies how many folders to remove after the file is
deleted; it's 1 in this case, because this was in the only link in the
program group.
What am I doing wrong?
procedure RemoveShortCut(IconText, Destination : string; WithDirectories:
Byte = 0);
VAR
FName: String;
P : Byte;
L : Integer;
BEGIN
FName := Destination + IconText + '.lnk';
DeleteFile(PChar(FName));
{ Refresh desktop: }
SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_FLUSHNOWAIT, nil, nil);
FOR P := 1 TO WithDirectories DO
BEGIN
L := Length(FName);
WHILE (L >= 0) AND (FName[L] <> '\') AND (FName[L] <> '/') DO
Dec(L);
IF L <> 0 THEN
BEGIN
FName := Copy(FName,1,L-1);
{ Is now something like: 'C:\Documents and
Settings\Administrator\Start Menu\Programs\TestGroupName' }
// fails too FName := Copy(FName,1,L);
RmDir(FName); <== IO Error 32
END;
END; { FOR P := 1 TO WithDirectories }
END; { RemoveShortCut }
TIA
Jan