Move to Recycle Bin III

Category: Files/Folders

Date: 02-16-2022

Return to Index


 
'Compilable Example:  (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
 
Function PBMain() As Long
   Local iResult As Long, temp As WStringZ * %Max_Path
   temp = "c:\_test\z.bas"
   If IsFile(temp) Then
      iResult = RecycleBin(temp)
      If iResult Then ? "FailedElse ? "Succeeded"
   Else
      ? "File not found!"
   End If
End Function
 
Function RecycleBin(szSource As WStringZ * %Max_Path) As Long
  Local shfo As SHFILEOPSTRUCTW
  shfo.wFunc = %FO_DELETE
  shfo.pFrom = VarPtr(szSource)
  shfo.fFlags = %FOF_ALLOWUNDO Or %FOF_NOCONFIRMATION
  SHFileOperation(shfo)
  Function = shfo.fAnyOperationsAborted  '%False=worked  %True=failed
End Function  
 
'gbs_01277
'Date: 05-11-2013


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm