PathMatchSpecExA
関数フラグ指定付きでファイル名がパターンに一致するか判定する。
シグネチャ
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
HRESULT PathMatchSpecExA(
LPCSTR pszFile,
LPCSTR pszSpec,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszFile | LPCSTR | in |
| pszSpec | LPCSTR | in |
| dwFlags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
HRESULT PathMatchSpecExA(
LPCSTR pszFile,
LPCSTR pszSpec,
DWORD dwFlags
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int PathMatchSpecExA(
[MarshalAs(UnmanagedType.LPStr)] string pszFile, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string pszSpec, // LPCSTR
uint dwFlags // DWORD
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function PathMatchSpecExA(
<MarshalAs(UnmanagedType.LPStr)> pszFile As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> pszSpec As String, ' LPCSTR
dwFlags As UInteger ' DWORD
) As Integer
End Function' pszFile : LPCSTR
' pszSpec : LPCSTR
' dwFlags : DWORD
Declare PtrSafe Function PathMatchSpecExA Lib "shlwapi" ( _
ByVal pszFile As String, _
ByVal pszSpec As String, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PathMatchSpecExA = ctypes.windll.shlwapi.PathMatchSpecExA
PathMatchSpecExA.restype = ctypes.c_int
PathMatchSpecExA.argtypes = [
wintypes.LPCSTR, # pszFile : LPCSTR
wintypes.LPCSTR, # pszSpec : LPCSTR
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
PathMatchSpecExA = Fiddle::Function.new(
lib['PathMatchSpecExA'],
[
Fiddle::TYPE_VOIDP, # pszFile : LPCSTR
Fiddle::TYPE_VOIDP, # pszSpec : LPCSTR
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "shlwapi")]
extern "system" {
fn PathMatchSpecExA(
pszFile: *const u8, // LPCSTR
pszSpec: *const u8, // LPCSTR
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi)]
public static extern int PathMatchSpecExA([MarshalAs(UnmanagedType.LPStr)] string pszFile, [MarshalAs(UnmanagedType.LPStr)] string pszSpec, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_PathMatchSpecExA' -Namespace Win32 -PassThru
# $api::PathMatchSpecExA(pszFile, pszSpec, dwFlags)#uselib "SHLWAPI.dll"
#func global PathMatchSpecExA "PathMatchSpecExA" sptr, sptr, sptr
; PathMatchSpecExA pszFile, pszSpec, dwFlags ; 戻り値は stat
; pszFile : LPCSTR -> "sptr"
; pszSpec : LPCSTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHLWAPI.dll"
#cfunc global PathMatchSpecExA "PathMatchSpecExA" str, str, int
; res = PathMatchSpecExA(pszFile, pszSpec, dwFlags)
; pszFile : LPCSTR -> "str"
; pszSpec : LPCSTR -> "str"
; dwFlags : DWORD -> "int"; HRESULT PathMatchSpecExA(LPCSTR pszFile, LPCSTR pszSpec, DWORD dwFlags)
#uselib "SHLWAPI.dll"
#cfunc global PathMatchSpecExA "PathMatchSpecExA" str, str, int
; res = PathMatchSpecExA(pszFile, pszSpec, dwFlags)
; pszFile : LPCSTR -> "str"
; pszSpec : LPCSTR -> "str"
; dwFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procPathMatchSpecExA = shlwapi.NewProc("PathMatchSpecExA")
)
// pszFile (LPCSTR), pszSpec (LPCSTR), dwFlags (DWORD)
r1, _, err := procPathMatchSpecExA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszFile))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszSpec))),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction PathMatchSpecExA(
pszFile: PAnsiChar; // LPCSTR
pszSpec: PAnsiChar; // LPCSTR
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'SHLWAPI.dll' name 'PathMatchSpecExA';result := DllCall("SHLWAPI\PathMatchSpecExA"
, "AStr", pszFile ; LPCSTR
, "AStr", pszSpec ; LPCSTR
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●PathMatchSpecExA(pszFile, pszSpec, dwFlags) = DLL("SHLWAPI.dll", "int PathMatchSpecExA(char*, char*, dword)")
# 呼び出し: PathMatchSpecExA(pszFile, pszSpec, dwFlags)
# pszFile : LPCSTR -> "char*"
# pszSpec : LPCSTR -> "char*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。