c00000fd
c00000fd

Reputation: 22327

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?)

Upvotes: 5

Views: 2089

Answers (1)

c00000fd
c00000fd

Reputation: 22327

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);

Upvotes: 3

Related Questions