删除文件到回收站

void DeleteToRec(CString& strFileName) { //strFileName必须是绝对路径,相对路径会出错 wchar_t buff[1024]; ZeroMemory(buff, sizeof(buff)); _tcscpy_s(buff, strFileName); buff[strFileName.GetLength() + 1] = 0;//结尾必须有两个NULL SHFILEOPSTRUCT fop; ZeroMemory(&fop, sizeof(fop)); fop.wFunc = FO_DELETE; fop.pFrom = buff; fop.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; SHFileOperation(&fop); }

你可能感兴趣的:(删除文件到回收站)