gpt4 book ai didi

c++ - SHFileOperation 返回 1223,仅在 xp 上

转载 作者:太空宇宙 更新时间:2023-11-04 13:27:03 25 4
gpt4 key购买 nike

我有一个小控制台应用程序可以将所有文件从一个 USB 驱动器复制到另一个:

void CopyAllFiles(wchar_t** source, wchar_t* destination)
{
WCHAR src[MAX_PATH + 1], dest[MAX_PATH + 1];
wsprintf(src, L"%s*\0", *source);
src[wcslen(src) + 1] = 0; \\Just to be sure it ends with "\0\0"
wsprintf(dest, L"%s\0", destination);
dest[wcslen(dest) + 1] = 0;

cout << "Source: " << src << endl << "Destination: " << dest << endl;

SHFILEOPSTRUCT s = { 0 };
s.hwnd = nullptr;
s.wFunc = FO_COPY;
s.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS | FOF_RENAMEONCOLLISION | ;
s.pTo = dest;
s.pFrom = src;
cerr << "SHFileOperation returns " << SHFileOperation(&s) << endl;
}

这在 Windows 8.1 上运行良好,但当我尝试在具有相同配置的 WinXP 上运行它时,SHFileOperation 返回 1223。我尝试将 1GB 从 4GB USB 复制到空的 64GB USB。

知道为什么会这样吗?

最佳答案

好吧,我没有意识到我必须指定现有目录的路径 - 在 Win8 上它会自动创建目录,在 xp 上则不会。

非常感谢你们所有人的帮助和建议。

关于c++ - SHFileOperation 返回 1223,仅在 xp 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32993822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com