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