Problems in the function SHFileOperation. I use it to copy the folder, but the function ends with error code 87 or 2. There is the following code:
#include <iostream> #include <string> #include <windows.h> #include <shellapi.h> int main(int argc, char* argv[]) { setlocale(LC_ALL, "Russian"); std::string directionNames = argv[1]; std::string sourceDir = directionNames + "\\*\0\0"; std::string targetDir = directionNames + "_delComments"; SHFILEOPSTRUCT SHF; SHF.hwnd = 0; SHF.wFunc = FO_COPY; SHF.pFrom = sourceDir.c_str(); SHF.pTo = targetDir.c_str(); SHF.fFlags = 512; SHF.hNameMappings = 0; SHF.lpszProgressTitle = 0; int result = SHFileOperation(&SHF); if (result != 0) if (SHF.fAnyOperationsAborted) std::cout << "Выполнение операции прервано пользователем\n"; else std::cout << "Ошибка выполнения операции\n"; else std::cout << "Операция успешно завершена\n"; std::cout << result << std::endl; std::cin.get(); return 0; } Also there is a situation when once for 15-20 starts copying is performed successfully. What could be the problem?
ZeroMemory(&SHF, sizeof(SHFILEOPSTRUCT));brought no results - Max Yu