ホーム › System.Diagnostics.Debug › EnumDirTreeW
EnumDirTreeW
関数ディレクトリツリーを列挙し一致ファイルをコールバックへ通知する。
シグネチャ
// dbghelp.dll (Unicode / -W)
#include <windows.h>
BOOL EnumDirTreeW(
HANDLE hProcess, // optional
LPCWSTR RootPath,
LPCWSTR InputPathName,
LPWSTR OutputPathBuffer, // optional
PENUMDIRTREE_CALLBACKW cb, // optional
void* data // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hProcess | HANDLE | inoptional |
| RootPath | LPCWSTR | in |
| InputPathName | LPCWSTR | in |
| OutputPathBuffer | LPWSTR | outoptional |
| cb | PENUMDIRTREE_CALLBACKW | inoptional |
| data | void* | inoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// dbghelp.dll (Unicode / -W)
#include <windows.h>
BOOL EnumDirTreeW(
HANDLE hProcess, // optional
LPCWSTR RootPath,
LPCWSTR InputPathName,
LPWSTR OutputPathBuffer, // optional
PENUMDIRTREE_CALLBACKW cb, // optional
void* data // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool EnumDirTreeW(
IntPtr hProcess, // HANDLE optional
[MarshalAs(UnmanagedType.LPWStr)] string RootPath, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string InputPathName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder OutputPathBuffer, // LPWSTR optional, out
IntPtr cb, // PENUMDIRTREE_CALLBACKW optional
IntPtr data // void* optional
);<DllImport("dbghelp.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function EnumDirTreeW(
hProcess As IntPtr, ' HANDLE optional
<MarshalAs(UnmanagedType.LPWStr)> RootPath As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> InputPathName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> OutputPathBuffer As System.Text.StringBuilder, ' LPWSTR optional, out
cb As IntPtr, ' PENUMDIRTREE_CALLBACKW optional
data As IntPtr ' void* optional
) As Boolean
End Function' hProcess : HANDLE optional
' RootPath : LPCWSTR
' InputPathName : LPCWSTR
' OutputPathBuffer : LPWSTR optional, out
' cb : PENUMDIRTREE_CALLBACKW optional
' data : void* optional
Declare PtrSafe Function EnumDirTreeW Lib "dbghelp" ( _
ByVal hProcess As LongPtr, _
ByVal RootPath As LongPtr, _
ByVal InputPathName As LongPtr, _
ByVal OutputPathBuffer As LongPtr, _
ByVal cb As LongPtr, _
ByVal data 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
EnumDirTreeW = ctypes.windll.dbghelp.EnumDirTreeW
EnumDirTreeW.restype = wintypes.BOOL
EnumDirTreeW.argtypes = [
wintypes.HANDLE, # hProcess : HANDLE optional
wintypes.LPCWSTR, # RootPath : LPCWSTR
wintypes.LPCWSTR, # InputPathName : LPCWSTR
wintypes.LPWSTR, # OutputPathBuffer : LPWSTR optional, out
ctypes.c_void_p, # cb : PENUMDIRTREE_CALLBACKW optional
ctypes.POINTER(None), # data : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dbghelp.dll')
EnumDirTreeW = Fiddle::Function.new(
lib['EnumDirTreeW'],
[
Fiddle::TYPE_VOIDP, # hProcess : HANDLE optional
Fiddle::TYPE_VOIDP, # RootPath : LPCWSTR
Fiddle::TYPE_VOIDP, # InputPathName : LPCWSTR
Fiddle::TYPE_VOIDP, # OutputPathBuffer : LPWSTR optional, out
Fiddle::TYPE_VOIDP, # cb : PENUMDIRTREE_CALLBACKW optional
Fiddle::TYPE_VOIDP, # data : void* optional
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "dbghelp")]
extern "system" {
fn EnumDirTreeW(
hProcess: *mut core::ffi::c_void, // HANDLE optional
RootPath: *const u16, // LPCWSTR
InputPathName: *const u16, // LPCWSTR
OutputPathBuffer: *mut u16, // LPWSTR optional, out
cb: *const core::ffi::c_void, // PENUMDIRTREE_CALLBACKW optional
data: *mut () // void* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool EnumDirTreeW(IntPtr hProcess, [MarshalAs(UnmanagedType.LPWStr)] string RootPath, [MarshalAs(UnmanagedType.LPWStr)] string InputPathName, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder OutputPathBuffer, IntPtr cb, IntPtr data);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_EnumDirTreeW' -Namespace Win32 -PassThru
# $api::EnumDirTreeW(hProcess, RootPath, InputPathName, OutputPathBuffer, cb, data)#uselib "dbghelp.dll"
#func global EnumDirTreeW "EnumDirTreeW" wptr, wptr, wptr, wptr, wptr, wptr
; EnumDirTreeW hProcess, RootPath, InputPathName, varptr(OutputPathBuffer), cb, data ; 戻り値は stat
; hProcess : HANDLE optional -> "wptr"
; RootPath : LPCWSTR -> "wptr"
; InputPathName : LPCWSTR -> "wptr"
; OutputPathBuffer : LPWSTR optional, out -> "wptr"
; cb : PENUMDIRTREE_CALLBACKW optional -> "wptr"
; data : void* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "dbghelp.dll" #cfunc global EnumDirTreeW "EnumDirTreeW" sptr, wstr, wstr, var, sptr, sptr ; res = EnumDirTreeW(hProcess, RootPath, InputPathName, OutputPathBuffer, cb, data) ; hProcess : HANDLE optional -> "sptr" ; RootPath : LPCWSTR -> "wstr" ; InputPathName : LPCWSTR -> "wstr" ; OutputPathBuffer : LPWSTR optional, out -> "var" ; cb : PENUMDIRTREE_CALLBACKW optional -> "sptr" ; data : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "dbghelp.dll" #cfunc global EnumDirTreeW "EnumDirTreeW" sptr, wstr, wstr, sptr, sptr, sptr ; res = EnumDirTreeW(hProcess, RootPath, InputPathName, varptr(OutputPathBuffer), cb, data) ; hProcess : HANDLE optional -> "sptr" ; RootPath : LPCWSTR -> "wstr" ; InputPathName : LPCWSTR -> "wstr" ; OutputPathBuffer : LPWSTR optional, out -> "sptr" ; cb : PENUMDIRTREE_CALLBACKW optional -> "sptr" ; data : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL EnumDirTreeW(HANDLE hProcess, LPCWSTR RootPath, LPCWSTR InputPathName, LPWSTR OutputPathBuffer, PENUMDIRTREE_CALLBACKW cb, void* data) #uselib "dbghelp.dll" #cfunc global EnumDirTreeW "EnumDirTreeW" intptr, wstr, wstr, var, intptr, intptr ; res = EnumDirTreeW(hProcess, RootPath, InputPathName, OutputPathBuffer, cb, data) ; hProcess : HANDLE optional -> "intptr" ; RootPath : LPCWSTR -> "wstr" ; InputPathName : LPCWSTR -> "wstr" ; OutputPathBuffer : LPWSTR optional, out -> "var" ; cb : PENUMDIRTREE_CALLBACKW optional -> "intptr" ; data : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL EnumDirTreeW(HANDLE hProcess, LPCWSTR RootPath, LPCWSTR InputPathName, LPWSTR OutputPathBuffer, PENUMDIRTREE_CALLBACKW cb, void* data) #uselib "dbghelp.dll" #cfunc global EnumDirTreeW "EnumDirTreeW" intptr, wstr, wstr, intptr, intptr, intptr ; res = EnumDirTreeW(hProcess, RootPath, InputPathName, varptr(OutputPathBuffer), cb, data) ; hProcess : HANDLE optional -> "intptr" ; RootPath : LPCWSTR -> "wstr" ; InputPathName : LPCWSTR -> "wstr" ; OutputPathBuffer : LPWSTR optional, out -> "intptr" ; cb : PENUMDIRTREE_CALLBACKW optional -> "intptr" ; data : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
procEnumDirTreeW = dbghelp.NewProc("EnumDirTreeW")
)
// hProcess (HANDLE optional), RootPath (LPCWSTR), InputPathName (LPCWSTR), OutputPathBuffer (LPWSTR optional, out), cb (PENUMDIRTREE_CALLBACKW optional), data (void* optional)
r1, _, err := procEnumDirTreeW.Call(
uintptr(hProcess),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(RootPath))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(InputPathName))),
uintptr(OutputPathBuffer),
uintptr(cb),
uintptr(data),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction EnumDirTreeW(
hProcess: THandle; // HANDLE optional
RootPath: PWideChar; // LPCWSTR
InputPathName: PWideChar; // LPCWSTR
OutputPathBuffer: PWideChar; // LPWSTR optional, out
cb: Pointer; // PENUMDIRTREE_CALLBACKW optional
data: Pointer // void* optional
): BOOL; stdcall;
external 'dbghelp.dll' name 'EnumDirTreeW';result := DllCall("dbghelp\EnumDirTreeW"
, "Ptr", hProcess ; HANDLE optional
, "WStr", RootPath ; LPCWSTR
, "WStr", InputPathName ; LPCWSTR
, "Ptr", OutputPathBuffer ; LPWSTR optional, out
, "Ptr", cb ; PENUMDIRTREE_CALLBACKW optional
, "Ptr", data ; void* optional
, "Int") ; return: BOOL●EnumDirTreeW(hProcess, RootPath, InputPathName, OutputPathBuffer, cb, data) = DLL("dbghelp.dll", "bool EnumDirTreeW(void*, char*, char*, char*, void*, void*)")
# 呼び出し: EnumDirTreeW(hProcess, RootPath, InputPathName, OutputPathBuffer, cb, data)
# hProcess : HANDLE optional -> "void*"
# RootPath : LPCWSTR -> "char*"
# InputPathName : LPCWSTR -> "char*"
# OutputPathBuffer : LPWSTR optional, out -> "char*"
# cb : PENUMDIRTREE_CALLBACKW optional -> "void*"
# data : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。