PathFindSuffixArrayW
関数指定した接尾辞配列のいずれかにパスが一致するか調べる。
シグネチャ
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
LPWSTR PathFindSuffixArrayW(
LPCWSTR pszPath,
LPCWSTR* apszSuffix,
INT iArraySize
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszPath | LPCWSTR | in |
| apszSuffix | LPCWSTR* | in |
| iArraySize | INT | in |
戻り値の型: LPWSTR
各言語での呼び出し定義
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
LPWSTR PathFindSuffixArrayW(
LPCWSTR pszPath,
LPCWSTR* apszSuffix,
INT iArraySize
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr PathFindSuffixArrayW(
[MarshalAs(UnmanagedType.LPWStr)] string pszPath, // LPCWSTR
IntPtr apszSuffix, // LPCWSTR*
int iArraySize // INT
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PathFindSuffixArrayW(
<MarshalAs(UnmanagedType.LPWStr)> pszPath As String, ' LPCWSTR
apszSuffix As IntPtr, ' LPCWSTR*
iArraySize As Integer ' INT
) As IntPtr
End Function' pszPath : LPCWSTR
' apszSuffix : LPCWSTR*
' iArraySize : INT
Declare PtrSafe Function PathFindSuffixArrayW Lib "shlwapi" ( _
ByVal pszPath As LongPtr, _
ByVal apszSuffix As LongPtr, _
ByVal iArraySize As Long) As LongPtr
' 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
PathFindSuffixArrayW = ctypes.windll.shlwapi.PathFindSuffixArrayW
PathFindSuffixArrayW.restype = wintypes.LPWSTR
PathFindSuffixArrayW.argtypes = [
wintypes.LPCWSTR, # pszPath : LPCWSTR
ctypes.c_void_p, # apszSuffix : LPCWSTR*
ctypes.c_int, # iArraySize : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
PathFindSuffixArrayW = Fiddle::Function.new(
lib['PathFindSuffixArrayW'],
[
Fiddle::TYPE_VOIDP, # pszPath : LPCWSTR
Fiddle::TYPE_VOIDP, # apszSuffix : LPCWSTR*
Fiddle::TYPE_INT, # iArraySize : INT
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shlwapi")]
extern "system" {
fn PathFindSuffixArrayW(
pszPath: *const u16, // LPCWSTR
apszSuffix: *const *const u16, // LPCWSTR*
iArraySize: i32 // INT
) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr PathFindSuffixArrayW([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr apszSuffix, int iArraySize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_PathFindSuffixArrayW' -Namespace Win32 -PassThru
# $api::PathFindSuffixArrayW(pszPath, apszSuffix, iArraySize)#uselib "SHLWAPI.dll"
#func global PathFindSuffixArrayW "PathFindSuffixArrayW" wptr, wptr, wptr
; PathFindSuffixArrayW pszPath, varptr(apszSuffix), iArraySize ; 戻り値は stat
; pszPath : LPCWSTR -> "wptr"
; apszSuffix : LPCWSTR* -> "wptr"
; iArraySize : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHLWAPI.dll" #cfunc global PathFindSuffixArrayW "PathFindSuffixArrayW" wstr, var, int ; res = PathFindSuffixArrayW(pszPath, apszSuffix, iArraySize) ; pszPath : LPCWSTR -> "wstr" ; apszSuffix : LPCWSTR* -> "var" ; iArraySize : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHLWAPI.dll" #cfunc global PathFindSuffixArrayW "PathFindSuffixArrayW" wstr, sptr, int ; res = PathFindSuffixArrayW(pszPath, varptr(apszSuffix), iArraySize) ; pszPath : LPCWSTR -> "wstr" ; apszSuffix : LPCWSTR* -> "sptr" ; iArraySize : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; LPWSTR PathFindSuffixArrayW(LPCWSTR pszPath, LPCWSTR* apszSuffix, INT iArraySize) #uselib "SHLWAPI.dll" #cfunc global PathFindSuffixArrayW "PathFindSuffixArrayW" wstr, var, int ; res = PathFindSuffixArrayW(pszPath, apszSuffix, iArraySize) ; pszPath : LPCWSTR -> "wstr" ; apszSuffix : LPCWSTR* -> "var" ; iArraySize : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; LPWSTR PathFindSuffixArrayW(LPCWSTR pszPath, LPCWSTR* apszSuffix, INT iArraySize) #uselib "SHLWAPI.dll" #cfunc global PathFindSuffixArrayW "PathFindSuffixArrayW" wstr, intptr, int ; res = PathFindSuffixArrayW(pszPath, varptr(apszSuffix), iArraySize) ; pszPath : LPCWSTR -> "wstr" ; apszSuffix : LPCWSTR* -> "intptr" ; iArraySize : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procPathFindSuffixArrayW = shlwapi.NewProc("PathFindSuffixArrayW")
)
// pszPath (LPCWSTR), apszSuffix (LPCWSTR*), iArraySize (INT)
r1, _, err := procPathFindSuffixArrayW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPath))),
uintptr(apszSuffix),
uintptr(iArraySize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPWSTRfunction PathFindSuffixArrayW(
pszPath: PWideChar; // LPCWSTR
apszSuffix: PPWideChar; // LPCWSTR*
iArraySize: Integer // INT
): PWideChar; stdcall;
external 'SHLWAPI.dll' name 'PathFindSuffixArrayW';result := DllCall("SHLWAPI\PathFindSuffixArrayW"
, "WStr", pszPath ; LPCWSTR
, "Ptr", apszSuffix ; LPCWSTR*
, "Int", iArraySize ; INT
, "Ptr") ; return: LPWSTR●PathFindSuffixArrayW(pszPath, apszSuffix, iArraySize) = DLL("SHLWAPI.dll", "char* PathFindSuffixArrayW(char*, void*, int)")
# 呼び出し: PathFindSuffixArrayW(pszPath, apszSuffix, iArraySize)
# pszPath : LPCWSTR -> "char*"
# apszSuffix : LPCWSTR* -> "void*"
# iArraySize : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。