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