ゴミ箱のサイズ取得と削除 <TOP>
SHQueryRecycleBin
ごみ箱のサイズとアイテム数
SHUpdateRecycleBinIcon
ゴミ箱のアイコンをアップデート
SHEmptyRecycleBin
指定のドライブのごみ箱を空にする
MoveMemory
メモリの指定領域をコピー
'================================================================ '= ゴミ箱のサイズ取得と削除 '= (SHUpdateRecycleBinIcon.bas) '================================================================ #include "Windows.bi" Type ULARGE_INTEGER LowPart As Long HighPart As Long End Type Type SHQUERYRBINFO cbSize As Long i64Size As ULARGE_INTEGER i64NumItems As ULARGE_INTEGER End Type ' ごみ箱のサイズとアイテム数 Declare Function Api_SHQueryRecycleBin& Lib "shell32" Alias "SHQueryRecycleBinA" (ByVal pszRootPath$, pSHQueryRBInfo As SHQUERYRBINFO) ' ゴミ箱のアイコンをアップデート Declare Function Api_SHUpdateRecycleBinIcon& Lib "shell32" Alias "SHUpdateRecycleBinIcon" () ' 指定のドライブのごみ箱を空にする Declare Function Api_SHEmptyRecycleBin& Lib "shell32" Alias "SHEmptyRecycleBinA" (ByVal hWnd&, ByVal pszRootPath$, ByVal dwFlags&) ' メモリの指定領域をコピー Declare Sub MoveMemory Lib "Kernel32" Alias "RtlMoveMemory" (Dest As Any, Source As Any, ByVal length&) #define SHERB_NOCONFIRMATION &H1 '削除の確認をしない #define SHERB_NOPROGRESSUI &H2 '進行状況を表示しない #define SHERB_NOSOUND &H4 '処理完了時にサウンド無し #define GENERIC_READ -2147483648 '読み込みモード(&H80000000) #define vbNullString ByVal 0 '値0の文字列。値0を持つ文字列。空文字列ではない Var Shared Button1 As Object Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var si As SHQUERYRBINFO Var Ret As Long si.cbSize = Len(si) Ret = Api_SHQueryRecycleBin(vbNullString, si) If (si.i64Size.LowPart And GENERIC_READ) = GENERIC_READ Or si.i64Size.HighPart > 0 Then A% = MessageBox("ゴミ箱情報", "2GBを越えています" & Chr$(13, 10) & "ゴミ箱を空にしますか?", 4, 1) Else A% = MessageBox("ゴミ箱情報", Str$(si.i64Size.LowPart) & " bytes" & Chr$(13, 10) & Str$(si.i64NumItems.LowPart) & " files" & Chr$(13, 10) & "ゴミ箱を空にしますか?", 4, 1) End If If A% = 5 Then Ret = Api_SHEmptyRecycleBin(GethWnd, vbNullString, 0) Ret = Api_SHUpdateRecycleBinIcon End If End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End