Search code examples
winapireturn-valueshfileoperation

Explanation of return code from SHFileOperation()


Is there a reason SHFileOperation() returns 32?

My scenario is:

  • My current path is c:\foo\bar.
  • My file is in c:\foo
  • That file is going to the Recycle Bin.

This code is not listed as possible return value in here, and I don't know where to find the cause.

I am trying it on Windows 7 64-bit with MSVC 2010 Professional.

Could someone please explain where I can find the returned values documentation or some explanation for a reason of that failure?


Solution

  • SHFileOperation returns errors, which match to Winerror.h error values.

    32 is defined as ERROR_SHARING_VIOLATION, meaning "The process cannot access the file because it is being used by another process." This means that another process accesses the file you want to change by calling SHFileOperation.

    You might as well use Process Explorer's find-feature to find out, which process accesses the file you want to change.