- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 SHFileOperation 将文件/目录从一个位置复制到另一个位置。到目前为止,我的代码是,
for(int index=0; index < clbSource.GetCount();index++ )
{
SHFILEOPSTRUCT SHFileOp;
CString src,dest;
std::string NULLTermination="\\0\\0";
//Get source file/directory path from CListBox
int n = clbSource.GetTextLen(index);
clbSource.GetText(index, src.GetBuffer(n));
src.ReleaseBuffer();
CT2CA pszConvertedAnsiString (src);
std::string strStdS (pszConvertedAnsiString);
//replace single slash with double
size_t found = 0, next = 0;
while( (found = strStdS.find('\\', next)) != std::string::npos )
{
strStdS.insert(found, "\\");
next = found+4;
}
//Add double null termination
strStdS.append(NULLTermination);
std::wstring stempS = s2ws(strStdS);
//Get source file/directory path from CListBox
int m = clbDest.GetTextLen(index);
clbDest.GetText(index, dest.GetBuffer(n));
dest.ReleaseBuffer();
CT2CA pszConvertedAnsiStringd (dest);
std::string strStdD (pszConvertedAnsiStringd);
//replace single slash with double
size_t foundD = 0, nextD = 0;
while( (foundD = strStdD.find('\\', nextD)) != std::string::npos )
{
strStdD.insert(foundD, "\\");
nextD = foundD+4;
}
//Add double null termination
strStdD.append(NULLTermination);
std::wstring stempD = s2ws(strStdD);
// set up File Operation structure
ZeroMemory(&SHFileOp, sizeof(SHFILEOPSTRUCT));
// application the owner of the progress dialog.
SHFileOp.hwnd = GetSafeHwnd();
SHFileOp.wFunc = FO_COPY;
SHFileOp.pFrom = stempS.c_str();
//SHFileOp.pFrom = _T("E:\\backup\\java softwares\0\0");
SHFileOp.pTo = stempD.c_str();
//SHFileOp.pTo = _T("E:\\Tmp\0\0");
// Set the flags.
SHFileOp.fFlags = FOF_SIMPLEPROGRESS;
// Do it.
DWORD result = SHFileOperation(&SHFileOp);
//Check for success
if(result!=0)
{
::AfxMessageBox(ERR_MSG_FAILED_TO_COPY);
}
else
::AfxMessageBox(SUCCESS);
}
现在,结果是非零的,即 124。也通过此链接 System Error 124 - ERROR_INVALID_LEVEL with SHFileOperation .无法理解问题出在哪里。
注意:如果将硬编码值(如图所示)传递给“SHFileOp.pFrom”和“SHFileOp.pTo”,它可以正常工作。
有人能帮忙吗??
最佳答案
由于“历史原因”,
SHFileOperation
不返回标准的 Windows 错误代码。
MSDN:SHFileOperation , 在“返回值”下有一个可能的结果列表。
124 == 0x7C == The path in the source or destination or both was invalid.
检查您在结构中实际传递的值,路径转换中可能存在错误。
关于c++ - 错误 124 - SHFileOperation 的系统调用级别不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32738935/
这个旧的 C++ 函数适用于 32 位操作系统,但不适用于 64 位操作系统。我想复制文件夹。你知道我必须改变什么吗? ************** Exception Text ******
我正在尝试使用 SHFileOperation 将文件从一个位置复制到另一个位置: SHFILEOPSTRUCT fileop; fileop.hwnd = 0; fileop.wFunc = FO_
我正在尝试将目录复制到新位置。所以我使用 SHFileOperation/SHFILEOPSTRUCT 如下: SHFILEOPSTRUCT sf; memset(&sf,0,sizeof(sf));
我正在为 WiX 编写一个 C++ 自定义操作,它将在安装期间调用以删除安装程序安装的任何残留物。考虑以下代码: UINT __stdcall DeleteResidue(MSIHANDLE hIns
我正在尝试通过 SHFileOperationA 复制文件夹功能。这是我的代码。 int main() { SHFILEOPSTRUCTA sf; int result; s
我正在使用 SHFileOperation() 从特定路径删除目录。它是在多个线程中完成的,删除的目录总是不同的。 有时,它会抛出异常: Exception thrown at 0x00007FF8A
我想要 一个后台线程将通过 SHFileOperation 函数复制文件,一次始终只有一个 SHFileOperation (但我希望它位于线程中)< 我需要 UI 输出,因此需要使用 FOF_SIM
我正在使用以下代码删除大量文件 function FastDelete(const fromDir: string): Boolean; var fos: TSHFileOpStruct; beg
我正在使用 Shell API 复制包含文件的文件夹。 SHFILEOPSTRUCT sf = {0}; sf.wFunc = FO_COPY; sf.hwnd = 0; sf.fFlags = FO
我正在尝试编写一个程序,该程序将使用 Windows API 根据日期删除一组与特定命名模式(通配符)匹配的文件/文件夹 ... SHFILEOPSTRUCT shFileOpStruct =
我有一段代码使用带有 FO_MOVE 操作的 Windows SHFileOperation 函数。指定的其他标志是 FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_
我使用这个程序: function MoveToRecycle(sFileName: widestring): Boolean; var fos: TSHFileOpStructW; begin
我有一个基于 MDI 的框架应用程序正在调用 SHFileOperation,如下所示: SHFILEOPSTRUCT opDelFiles = {0}; opDelFiles.hwnd = AfxG
我想删除一个文件到回收站。我使用这段代码。 SHFILEOPSTRUCT FileOp; FileOp.hwnd = NULL; FileOp.wFunc=FO_DELETE;
我正在使用以下函数将文件删除到回收站:(C++、MFC、Unicode) bool DeleteFileToPaperbasket (CString filename) { TCHAR Buff
我正在尝试将 A 驱动器的内容复制到文件夹 C:\test\disk1 中。文件夹 disk1 已经存在。该程序编译但运行时出现错误 87。我知道错误 87 与无效参数有关,但我不确定问题出在哪里。有
我找到了一些使用 SHFileOperation() 复制文件的代码,但我对 SHFILEOPSTRUCT structure 中可用的所有标志感到困惑. 这就是我正在做的事情。我有一个递归过程,根据
这会在桌面上创建一个新文件夹,但不会将文件夹 .pfrom 的内容 move 到文件夹 .pTo。 int main() { SHFILEOPSTRUCT sf = {0}; TCHA
我有一个涉及 SHFileOperation 的问题: SHFILEOPSTRUCT sf2; memset(&sf2,0,sizeof(sf2)); sf2.hwnd = N
我正在尝试使用 SHFileOperation 将文件/目录从一个位置复制到另一个位置。到目前为止,我的代码是, for(int index=0; index < clbSource.GetC
我是一名优秀的程序员,十分优秀!