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

SymMatchStringW

関数
文字列がワイルドカード式に一致するか判定する。
DLLdbghelp.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり

シグネチャ

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

BOOL SymMatchStringW(
    LPCWSTR string,
    LPCWSTR expression,
    BOOL fCase
);

パラメーター

名前方向
stringLPCWSTRin
expressionLPCWSTRin
fCaseBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SymMatchStringW = ctypes.windll.dbghelp.SymMatchStringW
SymMatchStringW.restype = wintypes.BOOL
SymMatchStringW.argtypes = [
    wintypes.LPCWSTR,  # string : LPCWSTR
    wintypes.LPCWSTR,  # expression : LPCWSTR
    wintypes.BOOL,  # fCase : BOOL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dbghelp.dll')
SymMatchStringW = Fiddle::Function.new(
  lib['SymMatchStringW'],
  [
    Fiddle::TYPE_VOIDP,  # string : LPCWSTR
    Fiddle::TYPE_VOIDP,  # expression : LPCWSTR
    Fiddle::TYPE_INT,  # fCase : BOOL
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "dbghelp")]
extern "system" {
    fn SymMatchStringW(
        string: *const u16,  // LPCWSTR
        expression: *const u16,  // LPCWSTR
        fCase: i32  // BOOL
    ) -> 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 SymMatchStringW([MarshalAs(UnmanagedType.LPWStr)] string string, [MarshalAs(UnmanagedType.LPWStr)] string expression, bool fCase);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymMatchStringW' -Namespace Win32 -PassThru
# $api::SymMatchStringW(string, expression, fCase)
#uselib "dbghelp.dll"
#func global SymMatchStringW "SymMatchStringW" wptr, wptr, wptr
; SymMatchStringW string, expression, fCase   ; 戻り値は stat
; string : LPCWSTR -> "wptr"
; expression : LPCWSTR -> "wptr"
; fCase : BOOL -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "dbghelp.dll"
#cfunc global SymMatchStringW "SymMatchStringW" wstr, wstr, int
; res = SymMatchStringW(string, expression, fCase)
; string : LPCWSTR -> "wstr"
; expression : LPCWSTR -> "wstr"
; fCase : BOOL -> "int"
; BOOL SymMatchStringW(LPCWSTR string, LPCWSTR expression, BOOL fCase)
#uselib "dbghelp.dll"
#cfunc global SymMatchStringW "SymMatchStringW" wstr, wstr, int
; res = SymMatchStringW(string, expression, fCase)
; string : LPCWSTR -> "wstr"
; expression : LPCWSTR -> "wstr"
; fCase : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
	procSymMatchStringW = dbghelp.NewProc("SymMatchStringW")
)

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