Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a special method to remove a shortcut from a desktop?

I created a shortcut (.lnk) file on the desktop using the IShellLink interface similar to the code described at the bottom of this page.

So my assumption was that to remove this shortcut I could simply call DeleteFile on the .lnk file, but evidently it is not enough... if I do that I get a remnant of the shortcut file that looks like this:

enter image description here

But what is interesting is that if I browse files in the desktop folder, say with Windows Explorer, the .lnk file is not actually there. What I see is some artifact on the desktop GUI surface.

Any idea how to remove a shortcut (the way Microsoft wants it done?)

like image 556
c00000fd Avatar asked Oct 21 '22 22:10

c00000fd


1 Answers

OK, per suggestion above, here's the API that needs to be called afterwards to refresh the shell:

SHChangeNotify(SHCNE_DELETE, SHCNF_PATH | SHCNF_FLUSHNOWAIT, pDeletedFilePath, NULL);
like image 182
c00000fd Avatar answered Oct 24 '22 17:10

c00000fd