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