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

SymMatchString

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

シグネチャ

// dbghelp.dll  (ANSI / -A)
#include <windows.h>

BOOL SymMatchString(
    LPCSTR string,
    LPCSTR expression,
    BOOL fCase
);

パラメーター

名前方向
stringLPCSTRin
expressionLPCSTRin
fCaseBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

// dbghelp.dll  (ANSI / -A)
#include <windows.h>

BOOL SymMatchString(
    LPCSTR string,
    LPCSTR expression,
    BOOL fCase
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SymMatchString(
    [MarshalAs(UnmanagedType.LPStr)] string string,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string expression,   // LPCSTR
    bool fCase   // BOOL
);
<DllImport("dbghelp.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SymMatchString(
    <MarshalAs(UnmanagedType.LPStr)> [string] As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> expression As String,   ' LPCSTR
    fCase As Boolean   ' BOOL
) As Boolean
End Function
' string : LPCSTR
' expression : LPCSTR
' fCase : BOOL
Declare PtrSafe Function SymMatchString Lib "dbghelp" ( _
    ByVal string As String, _
    ByVal expression As String, _
    ByVal fCase As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SymMatchString = ctypes.windll.dbghelp.SymMatchString
SymMatchString.restype = wintypes.BOOL
SymMatchString.argtypes = [
    wintypes.LPCSTR,  # string : LPCSTR
    wintypes.LPCSTR,  # expression : LPCSTR
    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')
SymMatchString = Fiddle::Function.new(
  lib['SymMatchString'],
  [
    Fiddle::TYPE_VOIDP,  # string : LPCSTR
    Fiddle::TYPE_VOIDP,  # expression : LPCSTR
    Fiddle::TYPE_INT,  # fCase : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "dbghelp")]
extern "system" {
    fn SymMatchString(
        string: *const u8,  // LPCSTR
        expression: *const u8,  // LPCSTR
        fCase: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool SymMatchString([MarshalAs(UnmanagedType.LPStr)] string string, [MarshalAs(UnmanagedType.LPStr)] string expression, bool fCase);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymMatchString' -Namespace Win32 -PassThru
# $api::SymMatchString(string, expression, fCase)
#uselib "dbghelp.dll"
#func global SymMatchString "SymMatchString" sptr, sptr, sptr
; SymMatchString string, expression, fCase   ; 戻り値は stat
; string : LPCSTR -> "sptr"
; expression : LPCSTR -> "sptr"
; fCase : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "dbghelp.dll"
#cfunc global SymMatchString "SymMatchString" str, str, int
; res = SymMatchString(string, expression, fCase)
; string : LPCSTR -> "str"
; expression : LPCSTR -> "str"
; fCase : BOOL -> "int"
; BOOL SymMatchString(LPCSTR string, LPCSTR expression, BOOL fCase)
#uselib "dbghelp.dll"
#cfunc global SymMatchString "SymMatchString" str, str, int
; res = SymMatchString(string, expression, fCase)
; string : LPCSTR -> "str"
; expression : LPCSTR -> "str"
; fCase : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
	procSymMatchString = dbghelp.NewProc("SymMatchString")
)

// string (LPCSTR), expression (LPCSTR), fCase (BOOL)
r1, _, err := procSymMatchString.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(string))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(expression))),
	uintptr(fCase),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SymMatchString(
  string: PAnsiChar;   // LPCSTR
  expression: PAnsiChar;   // LPCSTR
  fCase: BOOL   // BOOL
): BOOL; stdcall;
  external 'dbghelp.dll' name 'SymMatchString';
result := DllCall("dbghelp\SymMatchString"
    , "AStr", string   ; LPCSTR
    , "AStr", expression   ; LPCSTR
    , "Int", fCase   ; BOOL
    , "Int")   ; return: BOOL
●SymMatchString(string, expression, fCase) = DLL("dbghelp.dll", "bool SymMatchString(char*, char*, bool)")
# 呼び出し: SymMatchString(string, expression, fCase)
# string : LPCSTR -> "char*"
# expression : LPCSTR -> "char*"
# fCase : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。