+ Reply to Thread
Results 1 to 2 of 2

Thread: Delete desktop shortcut programmatically in WIN32/MFC application

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    29

    Delete desktop shortcut programmatically in WIN32/MFC application

    I need to develop a utility that can delete desktop shortcut programmatically in WIN32/MFC application. Can anybody help me implementing this?
    Thanks in advance.

  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    46
    Code:
    void DeleteDesktopShortcut(CString strShortcutName)
    {
    	LPITEMIDLIST pItemList = NULL ;
    	HRESULT hResult = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pItemList) ;
    	if (SUCCEEDED(hResult))
    	{
    		char szPath[_MAX_PATH] ;
    		SHGetPathFromIDList(pItemList, szPath) ;
    		CString strLinkName = CString(szPath) + "\\" + strShortcutName + ".lnk" ;
    		DeleteFile(strLinkName) ;
    	}
    }
    
    void UseIt()
    {
        DeleteDesktopShortcut("My Shortcut") ;
    }
    Use above example to delete desktop shortcut.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts