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

SymMatchStringA

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

シグネチャ

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

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

パラメーター

名前方向
stringLPCSTRin
expressionLPCSTRin
fCaseBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SymMatchStringA(
    LPCSTR string,
    LPCSTR expression,
    BOOL fCase
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool SymMatchStringA(
    [MarshalAs(UnmanagedType.LPStr)] string string,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string expression,   // LPCSTR
    bool fCase   // BOOL
);
<DllImport("dbghelp.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SymMatchStringA(
    <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 SymMatchStringA 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

SymMatchStringA = ctypes.windll.dbghelp.SymMatchStringA
SymMatchStringA.restype = wintypes.BOOL
SymMatchStringA.argtypes = [
    wintypes.LPCSTR,  # string : LPCSTR
    wintypes.LPCSTR,  # expression : LPCSTR
    wintypes.BOOL,  # fCase : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dbghelp.dll')
SymMatchStringA = Fiddle::Function.new(
  lib['SymMatchStringA'],
  [
    Fiddle::TYPE_VOIDP,  # string : LPCSTR
    Fiddle::TYPE_VOIDP,  # expression : LPCSTR
    Fiddle::TYPE_INT,  # fCase : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "dbghelp")]
extern "system" {
    fn SymMatchStringA(
        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)]
public static extern bool SymMatchStringA([MarshalAs(UnmanagedType.LPStr)] string string, [MarshalAs(UnmanagedType.LPStr)] string expression, bool fCase);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymMatchStringA' -Namespace Win32 -PassThru
# $api::SymMatchStringA(string, expression, fCase)
#uselib "dbghelp.dll"
#func global SymMatchStringA "SymMatchStringA" sptr, sptr, sptr
; SymMatchStringA string, expression, fCase   ; 戻り値は stat
; string : LPCSTR -> "sptr"
; expression : LPCSTR -> "sptr"
; fCase : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "dbghelp.dll"
#cfunc global SymMatchStringA "SymMatchStringA" str, str, int
; res = SymMatchStringA(string, expression, fCase)
; string : LPCSTR -> "str"
; expression : LPCSTR -> "str"
; fCase : BOOL -> "int"
; BOOL SymMatchStringA(LPCSTR string, LPCSTR expression, BOOL fCase)
#uselib "dbghelp.dll"
#cfunc global SymMatchStringA "SymMatchStringA" str, str, int
; res = SymMatchStringA(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")
	procSymMatchStringA = dbghelp.NewProc("SymMatchStringA")
)

// string (LPCSTR), expression (LPCSTR), fCase (BOOL)
r1, _, err := procSymMatchStringA.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 SymMatchStringA(
  string: PAnsiChar;   // LPCSTR
  expression: PAnsiChar;   // LPCSTR
  fCase: BOOL   // BOOL
): BOOL; stdcall;
  external 'dbghelp.dll' name 'SymMatchStringA';
result := DllCall("dbghelp\SymMatchStringA"
    , "AStr", string   ; LPCSTR
    , "AStr", expression   ; LPCSTR
    , "Int", fCase   ; BOOL
    , "Int")   ; return: BOOL
●SymMatchStringA(string, expression, fCase) = DLL("dbghelp.dll", "bool SymMatchStringA(char*, char*, bool)")
# 呼び出し: SymMatchStringA(string, expression, fCase)
# string : LPCSTR -> "char*"
# expression : LPCSTR -> "char*"
# fCase : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。