Explanation of return code from SHFileOperation()

1.2k Views Asked by At

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?

2

There are 2 best solutions below

4
On BEST ANSWER

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.

1
On

From my testing (so verify yourself)

32 = File in use or perhaps file locked/protected. (Created an excel wkbk, opened, typed text, tried to delete)

2 = not found

0 = no issues

4, 8, 16 return codes seem likely