none
不知道是不是Windows7 的Bug RRS feed

  • 问题

  • 在WinXP中调用SHFileOperation,复制文件时,如果目标文件存在,点取消按钮后,该函数会返回非0,而在Win7中返回值总是0,真是不可思议。
    2010年8月9日 9:09

答案

  • It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.

    MSDN说的很清楚,最好检查fAnyOperationsAborted,如果用户取消操作,SHFileOperation也会返回0。


    LHL
    2010年8月10日 3:44

全部回复

  • 用IFileOperation看看

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    2010年8月10日 2:34
    版主
  • It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.

    MSDN说的很清楚,最好检查fAnyOperationsAborted,如果用户取消操作,SHFileOperation也会返回0。


    LHL
    2010年8月10日 3:44
  • LHL:

    我这的代码中写的是FALSE。谢谢你了,LHL。

    2010年8月12日 5:57