Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug › SymMatchFileNameW

SymMatchFileNameW

関数
ファイル名がパターンに一致するか照合する(Unicode版)。
DLLdbghelp.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり

シグネチャ

// dbghelp.dll  (Unicode / -W)
#include <windows.h>

BOOL SymMatchFileNameW(
    LPCWSTR FileName,
    LPCWSTR Match,
    LPWSTR* FileNameStop,   // optional
    LPWSTR* MatchStop   // optional
);

パラメーター

名前方向
FileNameLPCWSTRin
MatchLPCWSTRin
FileNameStopLPWSTR*outoptional
MatchStopLPWSTR*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

// dbghelp.dll  (Unicode / -W)
#include <windows.h>

BOOL SymMatchFileNameW(
    LPCWSTR FileName,
    LPCWSTR Match,
    LPWSTR* FileNameStop,   // optional
    LPWSTR* MatchStop   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SymMatchFileNameW(
    [MarshalAs(UnmanagedType.LPWStr)] string FileName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string Match,   // LPCWSTR
    IntPtr FileNameStop,   // LPWSTR* optional, out
    IntPtr MatchStop   // LPWSTR* optional, out
);
<DllImport("dbghelp.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SymMatchFileNameW(
    <MarshalAs(UnmanagedType.LPWStr)> FileName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> Match As String,   ' LPCWSTR
    FileNameStop As IntPtr,   ' LPWSTR* optional, out
    MatchStop As IntPtr   ' LPWSTR* optional, out
) As Boolean
End Function
' FileName : LPCWSTR
' Match : LPCWSTR
' FileNameStop : LPWSTR* optional, out
' MatchStop : LPWSTR* optional, out
Declare PtrSafe Function SymMatchFileNameW Lib "dbghelp" ( _
    ByVal FileName As LongPtr, _
    ByVal Match As LongPtr, _
    ByVal FileNameStop As LongPtr, _
    ByVal MatchStop 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

SymMatchFileNameW = ctypes.windll.dbghelp.SymMatchFileNameW
SymMatchFileNameW.restype = wintypes.BOOL
SymMatchFileNameW.argtypes = [
    wintypes.LPCWSTR,  # FileName : LPCWSTR
    wintypes.LPCWSTR,  # Match : LPCWSTR
    ctypes.c_void_p,  # FileNameStop : LPWSTR* optional, out
    ctypes.c_void_p,  # MatchStop : LPWSTR* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dbghelp.dll')
SymMatchFileNameW = Fiddle::Function.new(
  lib['SymMatchFileNameW'],
  [
    Fiddle::TYPE_VOIDP,  # FileName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # Match : LPCWSTR
    Fiddle::TYPE_VOIDP,  # FileNameStop : LPWSTR* optional, out
    Fiddle::TYPE_VOIDP,  # MatchStop : LPWSTR* optional, out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "dbghelp")]
extern "system" {
    fn SymMatchFileNameW(
        FileName: *const u16,  // LPCWSTR
        Match: *const u16,  // LPCWSTR
        FileNameStop: *mut *mut u16,  // LPWSTR* optional, out
        MatchStop: *mut *mut u16  // LPWSTR* optional, out
    ) -> 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 SymMatchFileNameW([MarshalAs(UnmanagedType.LPWStr)] string FileName, [MarshalAs(UnmanagedType.LPWStr)] string Match, IntPtr FileNameStop, IntPtr MatchStop);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymMatchFileNameW' -Namespace Win32 -PassThru
# $api::SymMatchFileNameW(FileName, Match, FileNameStop, MatchStop)
#uselib "dbghelp.dll"
#func global SymMatchFileNameW "SymMatchFileNameW" wptr, wptr, wptr, wptr
; SymMatchFileNameW FileName, Match, varptr(FileNameStop), varptr(MatchStop)   ; 戻り値は stat
; FileName : LPCWSTR -> "wptr"
; Match : LPCWSTR -> "wptr"
; FileNameStop : LPWSTR* optional, out -> "wptr"
; MatchStop : LPWSTR* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "dbghelp.dll"
#cfunc global SymMatchFileNameW "SymMatchFileNameW" wstr, wstr, var, var
; res = SymMatchFileNameW(FileName, Match, FileNameStop, MatchStop)
; FileName : LPCWSTR -> "wstr"
; Match : LPCWSTR -> "wstr"
; FileNameStop : LPWSTR* optional, out -> "var"
; MatchStop : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SymMatchFileNameW(LPCWSTR FileName, LPCWSTR Match, LPWSTR* FileNameStop, LPWSTR* MatchStop)
#uselib "dbghelp.dll"
#cfunc global SymMatchFileNameW "SymMatchFileNameW" wstr, wstr, var, var
; res = SymMatchFileNameW(FileName, Match, FileNameStop, MatchStop)
; FileName : LPCWSTR -> "wstr"
; Match : LPCWSTR -> "wstr"
; FileNameStop : LPWSTR* optional, out -> "var"
; MatchStop : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
	procSymMatchFileNameW = dbghelp.NewProc("SymMatchFileNameW")
)

// FileName (LPCWSTR), Match (LPCWSTR), FileNameStop (LPWSTR* optional, out), MatchStop (LPWSTR* optional, out)
r1, _, err := procSymMatchFileNameW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FileName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Match))),
	uintptr(FileNameStop),
	uintptr(MatchStop),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SymMatchFileNameW(
  FileName: PWideChar;   // LPCWSTR
  Match: PWideChar;   // LPCWSTR
  FileNameStop: PPWideChar;   // LPWSTR* optional, out
  MatchStop: PPWideChar   // LPWSTR* optional, out
): BOOL; stdcall;
  external 'dbghelp.dll' name 'SymMatchFileNameW';
result := DllCall("dbghelp\SymMatchFileNameW"
    , "WStr", FileName   ; LPCWSTR
    , "WStr", Match   ; LPCWSTR
    , "Ptr", FileNameStop   ; LPWSTR* optional, out
    , "Ptr", MatchStop   ; LPWSTR* optional, out
    , "Int")   ; return: BOOL
●SymMatchFileNameW(FileName, Match, FileNameStop, MatchStop) = DLL("dbghelp.dll", "bool SymMatchFileNameW(char*, char*, void*, void*)")
# 呼び出し: SymMatchFileNameW(FileName, Match, FileNameStop, MatchStop)
# FileName : LPCWSTR -> "char*"
# Match : LPCWSTR -> "char*"
# FileNameStop : LPWSTR* optional, out -> "void*"
# MatchStop : LPWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。