|
▼りすりす さん:
>ゴミ箱へ移動、作っていますので、できたら追加でアップしますね。
使い方、
SendToRecycleBin (FullFileName)
' こいつで消すと
' メニュー元に戻すが機能しない
' ゴミ箱で選択して右クリックメニューで元に戻すはできる
' 普通になにかファイルを削除をすると メニューでも選択できるみたい。
' この辺は謎です。
' SHFileOpStruct Module
Type SHFileOpStruct
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Long
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String
End Type
Const FO_MOVE = &H1
Const FO_COPY = &H2
Const FO_DELETE = &H3
Const FO_RENAME = &H4
Const FOF_MULTIDESTFILES = &H1
Const FOF_CONFIRMMOUSE = &H2
Const FOF_SILENT = &H4
Const FOF_RENAMEONCOLLISION = &H8
Const FOF_NOCONFIRMATION = &H10
Const FOF_WANTMAPPINGHANDLE = &H20
Const FOF_ALLOWUNDO = &H40
Const FOF_FILESONLY = &H80
Const FOF_SIMPLEPROGRESS = &H100
Const FOF_NOCONFIRMMKDIR = &H200
Const FOF_NOERRORUI = &H400
Declare Function SHFileOperation Lib "shell32" _
Alias "SHFileOperationA" _
(lpFileOp As SHFileOpStruct) As Long
Declare Function GetActiveWindow Lib "user32" () As Long
Public Sub SendToRecycleBin(ByVal FileName As String)
Dim SHF As SHFileOpStruct
With SHF
.hWnd = GetActiveWindow
.wFunc = FO_DELETE ' 削除する
.pFrom = FileName
' .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION ' ゴミ箱へ:確認なし
.fFlags = FOF_ALLOWUNDO + FOF_SILENT ' ゴミ箱へ:確認付き
.lpszProgressTitle = String(1, vbNull)
.pTo = String(1, vbNull)
End With
Call SHFileOperation(SHF)
End Sub
|
|