SHEmptyRecycleBinA
関数指定ドライブのごみ箱を空にする。
シグネチャ
// SHELL32.dll (ANSI / -A)
#include <windows.h>
HRESULT SHEmptyRecycleBinA(
HWND hwnd, // optional
LPCSTR pszRootPath, // optional
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwnd | HWND | inoptional |
| pszRootPath | LPCSTR | inoptional |
| dwFlags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// SHELL32.dll (ANSI / -A)
#include <windows.h>
HRESULT SHEmptyRecycleBinA(
HWND hwnd, // optional
LPCSTR pszRootPath, // optional
DWORD dwFlags
);[DllImport("SHELL32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int SHEmptyRecycleBinA(
IntPtr hwnd, // HWND optional
[MarshalAs(UnmanagedType.LPStr)] string pszRootPath, // LPCSTR optional
uint dwFlags // DWORD
);<DllImport("SHELL32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SHEmptyRecycleBinA(
hwnd As IntPtr, ' HWND optional
<MarshalAs(UnmanagedType.LPStr)> pszRootPath As String, ' LPCSTR optional
dwFlags As UInteger ' DWORD
) As Integer
End Function' hwnd : HWND optional
' pszRootPath : LPCSTR optional
' dwFlags : DWORD
Declare PtrSafe Function SHEmptyRecycleBinA Lib "shell32" ( _
ByVal hwnd As LongPtr, _
ByVal pszRootPath As String, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHEmptyRecycleBinA = ctypes.windll.shell32.SHEmptyRecycleBinA
SHEmptyRecycleBinA.restype = ctypes.c_int
SHEmptyRecycleBinA.argtypes = [
wintypes.HANDLE, # hwnd : HWND optional
wintypes.LPCSTR, # pszRootPath : LPCSTR optional
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHEmptyRecycleBinA = Fiddle::Function.new(
lib['SHEmptyRecycleBinA'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND optional
Fiddle::TYPE_VOIDP, # pszRootPath : LPCSTR optional
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn SHEmptyRecycleBinA(
hwnd: *mut core::ffi::c_void, // HWND optional
pszRootPath: *const u8, // LPCSTR optional
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll", CharSet = CharSet.Ansi)]
public static extern int SHEmptyRecycleBinA(IntPtr hwnd, [MarshalAs(UnmanagedType.LPStr)] string pszRootPath, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHEmptyRecycleBinA' -Namespace Win32 -PassThru
# $api::SHEmptyRecycleBinA(hwnd, pszRootPath, dwFlags)#uselib "SHELL32.dll"
#func global SHEmptyRecycleBinA "SHEmptyRecycleBinA" sptr, sptr, sptr
; SHEmptyRecycleBinA hwnd, pszRootPath, dwFlags ; 戻り値は stat
; hwnd : HWND optional -> "sptr"
; pszRootPath : LPCSTR optional -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHELL32.dll"
#cfunc global SHEmptyRecycleBinA "SHEmptyRecycleBinA" sptr, str, int
; res = SHEmptyRecycleBinA(hwnd, pszRootPath, dwFlags)
; hwnd : HWND optional -> "sptr"
; pszRootPath : LPCSTR optional -> "str"
; dwFlags : DWORD -> "int"; HRESULT SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
#uselib "SHELL32.dll"
#cfunc global SHEmptyRecycleBinA "SHEmptyRecycleBinA" intptr, str, int
; res = SHEmptyRecycleBinA(hwnd, pszRootPath, dwFlags)
; hwnd : HWND optional -> "intptr"
; pszRootPath : LPCSTR optional -> "str"
; dwFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHEmptyRecycleBinA = shell32.NewProc("SHEmptyRecycleBinA")
)
// hwnd (HWND optional), pszRootPath (LPCSTR optional), dwFlags (DWORD)
r1, _, err := procSHEmptyRecycleBinA.Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszRootPath))),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SHEmptyRecycleBinA(
hwnd: THandle; // HWND optional
pszRootPath: PAnsiChar; // LPCSTR optional
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'SHELL32.dll' name 'SHEmptyRecycleBinA';result := DllCall("SHELL32\SHEmptyRecycleBinA"
, "Ptr", hwnd ; HWND optional
, "AStr", pszRootPath ; LPCSTR optional
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●SHEmptyRecycleBinA(hwnd, pszRootPath, dwFlags) = DLL("SHELL32.dll", "int SHEmptyRecycleBinA(void*, char*, dword)")
# 呼び出し: SHEmptyRecycleBinA(hwnd, pszRootPath, dwFlags)
# hwnd : HWND optional -> "void*"
# pszRootPath : LPCSTR optional -> "char*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。