I use following code to delete a file. it wroks well.
SHFILEOPSTRUCT FileOp;
ZeroMemory(&FileOp, sizeof(SHFILEOPSTRUCT));
FileOp.hwnd = m_hAppHandle;
FileOp.wFunc = FO_DELETE; //delete
FileOp.pFrom = szPath;
FileOp.pTo = NULL;
FileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI;
FileOp.fAnyOperationsAborted = FALSE;
FileOp.hNameMappings = NULL;
FileOp.lpszProgressTitle = NULL;
SHFileOperation(&FileOp);
But rcently I found a strang thing, the reproduction step as follow: 1. install win2000 2. install MS office2003
the at the first time (and only the first time) I call "SHFileOperation" function to delete a file. then a system warnning message box show
"Windows cannot create a shortcut here. Do you want the shortcut to be placed on the desktop instead? "
no matter I choose "OK" or "NO" button to close the warnning message box. then, such warnning message box never show again, i.e. , after I close the warnning message box, I can call "SHFileOperation" function to delete a file without such system warnning message.
It is truely magic, It just happens one time.
Any guy kown some related information? Thanks.