shfileoperation 删除文件 FileDelete(CString strName)
From:http://blog.csdn.net/lvwx369/article/details/41440883
注意:其中namePath 为全局变量 Cstring namePath;
BOOL FileDelete(CString strName)
{
namePath = strName;
SHFILEOPSTRUCT FileOp;
ZeroMemory((void*)&FileOp, sizeof(SHFILEOPSTRUCT));
FileOp.fFlags = FOF_NOCONFIRMATION;
FileOp.hNameMappings = NULL;
FileOp.hwnd = NULL;
FileOp.lpszProgressTitle = NULL;
FileOp.pFrom = namePath.GetBuffer(namePath.GetLength() + 2);//
FileOp.pTo = NULL;
FileOp.wFunc = FO_DELETE;
namePath.ReleaseBuffer();
return SHFileOperation(&FileOp) == 0;
}
如果问题解决起来不妥或者有更好的解决办法,麻烦请告知,帮助曾经和你一样的入门者,谢谢。