Search code examples
c++apiwinapikernel32shell32

DeleteFile (kernel32.dll) vs DeleteItem (shell32.dll)


What is the difference between the two functions?


Solution

    • DeleteFile is a low-level function that only deletes files on file systems and file shares supported by Windows.

    • IFileOperation::DeleteItem deletes items in the shell namespace.

    DeleteItem can in theory be used to delete control panel items, ftp files/folders and anything else that lives in the shell namespace and has the SFGAO_CANDELETE set. If the IShellItem passed to DeleteItem is a file on a normal file system then DeleteFile will ultimately be used to delete the file.

    The shell namespace model has existed since Windows 95 (IShellFolder and friends) but IFileOperation only exists in Vista and later and is part of the new shell copy engine added to those systems.