title: Using SHFileOperation: What errors are occuring
body: <p>I am using the function <code>SHFileOperation()</code> to send a file to the recycling bin and I am getting 2 errors that I do not know what they mean because with this function the error codes are not <code>GetLastError()</code> values.</p>
  
  <p>When the function <code>SHFileOperation()</code> fails the return values are 0x57 (decimal 87) and 0x2 (decimal 2). Can anyone help me discover the definitions of these errors (expecially when you consider with this function, the errors are not part of the <code>GetLastError()</code> codes).</p>
  
  <p>Some important information:</p>
  
  <ul>
  <li><p>I am using Windows 7 (&amp; I know that MSDN says to use IFileOperation instead of SHFileOperation but I want to make my app backwards compatable which is why I am using SHFileOperation). If the error is occuring because I am using SHFileOperation on Windows 7 what solution could I use to make this work on all versions of windows from 2000 &amp; up? </p></li>
  <li><p>I have debugged extensively &amp; as far as I know my SHFILEOPSTRUCT is correct (correct flags used, .pFrom is a double-null ended string). One thing I know for sure is that my path to the file is correct (leads to a real file &amp; it correctly formatted). </p></li>
  <li><p>About 2/5 times the SHFileOperation() works, meaning it sends the file to the recycle bin &amp; does not returns an error</p></li>
  </ul>
  
  <p>.</p>
  
  <pre><code> BOOL result;
   SHFILEOPSTRUCT fileStruct;
   fileStruct.hwnd = hwnd; 
   fileStruct.wFunc = FO_DELETE;
   fileStruct.pFrom = dest.c_str();
   fileStruct.fFlags = FOF_FILESONLY; // FOF_ALLOWUNDO
   fileStruct.fAnyOperationsAborted = result;
  
   // Call operation(delete file)
   int success = SHFileOperation( &amp;fileStruct );
  
   // if delete was successful
   if ( success != 0 ) 
   {
      printf( "%s \t %X %d \n", dest.c_str(), success, success );
      cout &lt;&lt; result &lt;&lt; endl;
  
      MessageBox( hwnd, "Failed to delete file", "Error", MB_OK|MB_ICONERROR );
      return;
   }
  </code></pre>