by Chaudhary Pradeep Kr Roy (6 Submissions)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 29th November 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This code can be used to send the file to the recycle bin. In general when u r deleting the file it gets deleted permanently. can be used to
API Declarations
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
'\ Here i am definig the structure
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long
End Type
'\ Below is the list of contants we will be using
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_SILENT = &H4
Public Sub SendFileToRecycleBin(FileName As String, Optional Confirm As Boolean = True, Optional Silent As Boolean = False)
Dim FileOp As SHFILEOPSTRUCT
'fills the file operation structure
With FileOp
.wFunc = FO_DELETE
.pFrom = FileName
.fFlags = FOF_ALLOWUNDO
If Not Confirm Then .fFlags = .fFlags + FOF_NOCONFIRMATION
If Silent Then .fFlags = .fFlags + FOF_SILENT
End With
SHFileOperation FileOp
End Sub
'Using function to the task
Private Sub Command1_Click()
SendFileToRecycleBin text1, False '\ Text1 is file name
End Sub
No comments have been posted about This code can be used to send the file to the recycle bin. In general when u r deleting the file it. Why not be the first to post a comment about This code can be used to send the file to the recycle bin. In general when u r deleting the file it.