头文件包含:
#include <WTypes.h>
#include <ShellAPI.h>
#include <tchar.h>
#include <WinNT.h>
#pragma comment(lib, "shell32.lib")
拷贝代码:
SHFILEOPSTRUCT lpsh;
ZeroMemory(&lpsh, sizeof(lpsh));
lpsh.hwnd = HWND_DESKTOP;
lpsh.fFlags = FOF_RENAMEONCOLLISION; // 有重名文件时自动添加“复件”前缀
lpsh.wFunc = FO_COPY; // 拷贝文件
lpsh.pFrom = tmpsrcpath; // 源文件路径
lpsh.pTo = tmpdespath; // 目标路径
if (0 != SHFileOperation(&lpsh))
{
mbStopped = true;
break;
}