SHQueryRecycleBinW
関数ごみ箱内の項目数と合計サイズを取得する。
シグネチャ
// SHELL32.dll (Unicode / -W)
#include <windows.h>
HRESULT SHQueryRecycleBinW(
LPCWSTR pszRootPath, // optional
SHQUERYRBINFO* pSHQueryRBInfo
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszRootPath | LPCWSTR | inoptional |
| pSHQueryRBInfo | SHQUERYRBINFO* | inout |
戻り値の型: HRESULT
各言語での呼び出し定義
// SHELL32.dll (Unicode / -W)
#include <windows.h>
HRESULT SHQueryRecycleBinW(
LPCWSTR pszRootPath, // optional
SHQUERYRBINFO* pSHQueryRBInfo
);[DllImport("SHELL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int SHQueryRecycleBinW(
[MarshalAs(UnmanagedType.LPWStr)] string pszRootPath, // LPCWSTR optional
IntPtr pSHQueryRBInfo // SHQUERYRBINFO* in/out
);<DllImport("SHELL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SHQueryRecycleBinW(
<MarshalAs(UnmanagedType.LPWStr)> pszRootPath As String, ' LPCWSTR optional
pSHQueryRBInfo As IntPtr ' SHQUERYRBINFO* in/out
) As Integer
End Function' pszRootPath : LPCWSTR optional
' pSHQueryRBInfo : SHQUERYRBINFO* in/out
Declare PtrSafe Function SHQueryRecycleBinW Lib "shell32" ( _
ByVal pszRootPath As LongPtr, _
ByVal pSHQueryRBInfo As LongPtr) 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
SHQueryRecycleBinW = ctypes.windll.shell32.SHQueryRecycleBinW
SHQueryRecycleBinW.restype = ctypes.c_int
SHQueryRecycleBinW.argtypes = [
wintypes.LPCWSTR, # pszRootPath : LPCWSTR optional
ctypes.c_void_p, # pSHQueryRBInfo : SHQUERYRBINFO* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHQueryRecycleBinW = Fiddle::Function.new(
lib['SHQueryRecycleBinW'],
[
Fiddle::TYPE_VOIDP, # pszRootPath : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pSHQueryRBInfo : SHQUERYRBINFO* in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shell32")]
extern "system" {
fn SHQueryRecycleBinW(
pszRootPath: *const u16, // LPCWSTR optional
pSHQueryRBInfo: *mut SHQUERYRBINFO // SHQUERYRBINFO* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode)]
public static extern int SHQueryRecycleBinW([MarshalAs(UnmanagedType.LPWStr)] string pszRootPath, IntPtr pSHQueryRBInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHQueryRecycleBinW' -Namespace Win32 -PassThru
# $api::SHQueryRecycleBinW(pszRootPath, pSHQueryRBInfo)#uselib "SHELL32.dll"
#func global SHQueryRecycleBinW "SHQueryRecycleBinW" wptr, wptr
; SHQueryRecycleBinW pszRootPath, varptr(pSHQueryRBInfo) ; 戻り値は stat
; pszRootPath : LPCWSTR optional -> "wptr"
; pSHQueryRBInfo : SHQUERYRBINFO* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHELL32.dll" #cfunc global SHQueryRecycleBinW "SHQueryRecycleBinW" wstr, var ; res = SHQueryRecycleBinW(pszRootPath, pSHQueryRBInfo) ; pszRootPath : LPCWSTR optional -> "wstr" ; pSHQueryRBInfo : SHQUERYRBINFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #cfunc global SHQueryRecycleBinW "SHQueryRecycleBinW" wstr, sptr ; res = SHQueryRecycleBinW(pszRootPath, varptr(pSHQueryRBInfo)) ; pszRootPath : LPCWSTR optional -> "wstr" ; pSHQueryRBInfo : SHQUERYRBINFO* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SHQueryRecycleBinW(LPCWSTR pszRootPath, SHQUERYRBINFO* pSHQueryRBInfo) #uselib "SHELL32.dll" #cfunc global SHQueryRecycleBinW "SHQueryRecycleBinW" wstr, var ; res = SHQueryRecycleBinW(pszRootPath, pSHQueryRBInfo) ; pszRootPath : LPCWSTR optional -> "wstr" ; pSHQueryRBInfo : SHQUERYRBINFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SHQueryRecycleBinW(LPCWSTR pszRootPath, SHQUERYRBINFO* pSHQueryRBInfo) #uselib "SHELL32.dll" #cfunc global SHQueryRecycleBinW "SHQueryRecycleBinW" wstr, intptr ; res = SHQueryRecycleBinW(pszRootPath, varptr(pSHQueryRBInfo)) ; pszRootPath : LPCWSTR optional -> "wstr" ; pSHQueryRBInfo : SHQUERYRBINFO* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHQueryRecycleBinW = shell32.NewProc("SHQueryRecycleBinW")
)
// pszRootPath (LPCWSTR optional), pSHQueryRBInfo (SHQUERYRBINFO* in/out)
r1, _, err := procSHQueryRecycleBinW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszRootPath))),
uintptr(pSHQueryRBInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SHQueryRecycleBinW(
pszRootPath: PWideChar; // LPCWSTR optional
pSHQueryRBInfo: Pointer // SHQUERYRBINFO* in/out
): Integer; stdcall;
external 'SHELL32.dll' name 'SHQueryRecycleBinW';result := DllCall("SHELL32\SHQueryRecycleBinW"
, "WStr", pszRootPath ; LPCWSTR optional
, "Ptr", pSHQueryRBInfo ; SHQUERYRBINFO* in/out
, "Int") ; return: HRESULT●SHQueryRecycleBinW(pszRootPath, pSHQueryRBInfo) = DLL("SHELL32.dll", "int SHQueryRecycleBinW(char*, void*)")
# 呼び出し: SHQueryRecycleBinW(pszRootPath, pSHQueryRBInfo)
# pszRootPath : LPCWSTR optional -> "char*"
# pSHQueryRBInfo : SHQUERYRBINFO* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。