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

SymFindFileInPathW

関数
検索パス内から条件に一致するシンボルファイルを検索する。
DLLdbghelp.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり

シグネチャ

// dbghelp.dll  (Unicode / -W)
#include <windows.h>

BOOL SymFindFileInPathW(
    HANDLE hprocess,
    LPCWSTR SearchPathA,   // optional
    LPCWSTR FileName,
    void* id,   // optional
    DWORD two,
    DWORD three,
    SYM_FIND_ID_OPTION flags,
    LPWSTR FoundFile,
    PFINDFILEINPATHCALLBACKW callback,   // optional
    void* context   // optional
);

パラメーター

名前方向
hprocessHANDLEin
SearchPathALPCWSTRinoptional
FileNameLPCWSTRin
idvoid*inoptional
twoDWORDin
threeDWORDin
flagsSYM_FIND_ID_OPTIONin
FoundFileLPWSTRout
callbackPFINDFILEINPATHCALLBACKWinoptional
contextvoid*inoptional

戻り値の型: BOOL

各言語での呼び出し定義

// dbghelp.dll  (Unicode / -W)
#include <windows.h>

BOOL SymFindFileInPathW(
    HANDLE hprocess,
    LPCWSTR SearchPathA,   // optional
    LPCWSTR FileName,
    void* id,   // optional
    DWORD two,
    DWORD three,
    SYM_FIND_ID_OPTION flags,
    LPWSTR FoundFile,
    PFINDFILEINPATHCALLBACKW callback,   // optional
    void* context   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SymFindFileInPathW(
    IntPtr hprocess,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string SearchPathA,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string FileName,   // LPCWSTR
    IntPtr id,   // void* optional
    uint two,   // DWORD
    uint three,   // DWORD
    uint flags,   // SYM_FIND_ID_OPTION
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder FoundFile,   // LPWSTR out
    IntPtr callback,   // PFINDFILEINPATHCALLBACKW optional
    IntPtr context   // void* optional
);
<DllImport("dbghelp.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SymFindFileInPathW(
    hprocess As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> SearchPathA As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> FileName As String,   ' LPCWSTR
    id As IntPtr,   ' void* optional
    two As UInteger,   ' DWORD
    three As UInteger,   ' DWORD
    flags As UInteger,   ' SYM_FIND_ID_OPTION
    <MarshalAs(UnmanagedType.LPWStr)> FoundFile As System.Text.StringBuilder,   ' LPWSTR out
    callback As IntPtr,   ' PFINDFILEINPATHCALLBACKW optional
    context As IntPtr   ' void* optional
) As Boolean
End Function
' hprocess : HANDLE
' SearchPathA : LPCWSTR optional
' FileName : LPCWSTR
' id : void* optional
' two : DWORD
' three : DWORD
' flags : SYM_FIND_ID_OPTION
' FoundFile : LPWSTR out
' callback : PFINDFILEINPATHCALLBACKW optional
' context : void* optional
Declare PtrSafe Function SymFindFileInPathW Lib "dbghelp" ( _
    ByVal hprocess As LongPtr, _
    ByVal SearchPathA As LongPtr, _
    ByVal FileName As LongPtr, _
    ByVal id As LongPtr, _
    ByVal two As Long, _
    ByVal three As Long, _
    ByVal flags As Long, _
    ByVal FoundFile As LongPtr, _
    ByVal callback As LongPtr, _
    ByVal context 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

SymFindFileInPathW = ctypes.windll.dbghelp.SymFindFileInPathW
SymFindFileInPathW.restype = wintypes.BOOL
SymFindFileInPathW.argtypes = [
    wintypes.HANDLE,  # hprocess : HANDLE
    wintypes.LPCWSTR,  # SearchPathA : LPCWSTR optional
    wintypes.LPCWSTR,  # FileName : LPCWSTR
    ctypes.POINTER(None),  # id : void* optional
    wintypes.DWORD,  # two : DWORD
    wintypes.DWORD,  # three : DWORD
    wintypes.DWORD,  # flags : SYM_FIND_ID_OPTION
    wintypes.LPWSTR,  # FoundFile : LPWSTR out
    ctypes.c_void_p,  # callback : PFINDFILEINPATHCALLBACKW optional
    ctypes.POINTER(None),  # context : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dbghelp.dll')
SymFindFileInPathW = Fiddle::Function.new(
  lib['SymFindFileInPathW'],
  [
    Fiddle::TYPE_VOIDP,  # hprocess : HANDLE
    Fiddle::TYPE_VOIDP,  # SearchPathA : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # FileName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # id : void* optional
    -Fiddle::TYPE_INT,  # two : DWORD
    -Fiddle::TYPE_INT,  # three : DWORD
    -Fiddle::TYPE_INT,  # flags : SYM_FIND_ID_OPTION
    Fiddle::TYPE_VOIDP,  # FoundFile : LPWSTR out
    Fiddle::TYPE_VOIDP,  # callback : PFINDFILEINPATHCALLBACKW optional
    Fiddle::TYPE_VOIDP,  # context : void* optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "dbghelp")]
extern "system" {
    fn SymFindFileInPathW(
        hprocess: *mut core::ffi::c_void,  // HANDLE
        SearchPathA: *const u16,  // LPCWSTR optional
        FileName: *const u16,  // LPCWSTR
        id: *mut (),  // void* optional
        two: u32,  // DWORD
        three: u32,  // DWORD
        flags: u32,  // SYM_FIND_ID_OPTION
        FoundFile: *mut u16,  // LPWSTR out
        callback: *const core::ffi::c_void,  // PFINDFILEINPATHCALLBACKW optional
        context: *mut ()  // void* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SymFindFileInPathW(IntPtr hprocess, [MarshalAs(UnmanagedType.LPWStr)] string SearchPathA, [MarshalAs(UnmanagedType.LPWStr)] string FileName, IntPtr id, uint two, uint three, uint flags, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder FoundFile, IntPtr callback, IntPtr context);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymFindFileInPathW' -Namespace Win32 -PassThru
# $api::SymFindFileInPathW(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
#uselib "dbghelp.dll"
#func global SymFindFileInPathW "SymFindFileInPathW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SymFindFileInPathW hprocess, SearchPathA, FileName, id, two, three, flags, varptr(FoundFile), callback, context   ; 戻り値は stat
; hprocess : HANDLE -> "wptr"
; SearchPathA : LPCWSTR optional -> "wptr"
; FileName : LPCWSTR -> "wptr"
; id : void* optional -> "wptr"
; two : DWORD -> "wptr"
; three : DWORD -> "wptr"
; flags : SYM_FIND_ID_OPTION -> "wptr"
; FoundFile : LPWSTR out -> "wptr"
; callback : PFINDFILEINPATHCALLBACKW optional -> "wptr"
; context : void* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "dbghelp.dll"
#cfunc global SymFindFileInPathW "SymFindFileInPathW" sptr, wstr, wstr, sptr, int, int, int, var, sptr, sptr
; res = SymFindFileInPathW(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
; hprocess : HANDLE -> "sptr"
; SearchPathA : LPCWSTR optional -> "wstr"
; FileName : LPCWSTR -> "wstr"
; id : void* optional -> "sptr"
; two : DWORD -> "int"
; three : DWORD -> "int"
; flags : SYM_FIND_ID_OPTION -> "int"
; FoundFile : LPWSTR out -> "var"
; callback : PFINDFILEINPATHCALLBACKW optional -> "sptr"
; context : void* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SymFindFileInPathW(HANDLE hprocess, LPCWSTR SearchPathA, LPCWSTR FileName, void* id, DWORD two, DWORD three, SYM_FIND_ID_OPTION flags, LPWSTR FoundFile, PFINDFILEINPATHCALLBACKW callback, void* context)
#uselib "dbghelp.dll"
#cfunc global SymFindFileInPathW "SymFindFileInPathW" intptr, wstr, wstr, intptr, int, int, int, var, intptr, intptr
; res = SymFindFileInPathW(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
; hprocess : HANDLE -> "intptr"
; SearchPathA : LPCWSTR optional -> "wstr"
; FileName : LPCWSTR -> "wstr"
; id : void* optional -> "intptr"
; two : DWORD -> "int"
; three : DWORD -> "int"
; flags : SYM_FIND_ID_OPTION -> "int"
; FoundFile : LPWSTR out -> "var"
; callback : PFINDFILEINPATHCALLBACKW optional -> "intptr"
; context : void* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
	procSymFindFileInPathW = dbghelp.NewProc("SymFindFileInPathW")
)

// hprocess (HANDLE), SearchPathA (LPCWSTR optional), FileName (LPCWSTR), id (void* optional), two (DWORD), three (DWORD), flags (SYM_FIND_ID_OPTION), FoundFile (LPWSTR out), callback (PFINDFILEINPATHCALLBACKW optional), context (void* optional)
r1, _, err := procSymFindFileInPathW.Call(
	uintptr(hprocess),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SearchPathA))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FileName))),
	uintptr(id),
	uintptr(two),
	uintptr(three),
	uintptr(flags),
	uintptr(FoundFile),
	uintptr(callback),
	uintptr(context),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SymFindFileInPathW(
  hprocess: THandle;   // HANDLE
  SearchPathA: PWideChar;   // LPCWSTR optional
  FileName: PWideChar;   // LPCWSTR
  id: Pointer;   // void* optional
  two: DWORD;   // DWORD
  three: DWORD;   // DWORD
  flags: DWORD;   // SYM_FIND_ID_OPTION
  FoundFile: PWideChar;   // LPWSTR out
  callback: Pointer;   // PFINDFILEINPATHCALLBACKW optional
  context: Pointer   // void* optional
): BOOL; stdcall;
  external 'dbghelp.dll' name 'SymFindFileInPathW';
result := DllCall("dbghelp\SymFindFileInPathW"
    , "Ptr", hprocess   ; HANDLE
    , "WStr", SearchPathA   ; LPCWSTR optional
    , "WStr", FileName   ; LPCWSTR
    , "Ptr", id   ; void* optional
    , "UInt", two   ; DWORD
    , "UInt", three   ; DWORD
    , "UInt", flags   ; SYM_FIND_ID_OPTION
    , "Ptr", FoundFile   ; LPWSTR out
    , "Ptr", callback   ; PFINDFILEINPATHCALLBACKW optional
    , "Ptr", context   ; void* optional
    , "Int")   ; return: BOOL
●SymFindFileInPathW(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context) = DLL("dbghelp.dll", "bool SymFindFileInPathW(void*, char*, char*, void*, dword, dword, dword, char*, void*, void*)")
# 呼び出し: SymFindFileInPathW(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
# hprocess : HANDLE -> "void*"
# SearchPathA : LPCWSTR optional -> "char*"
# FileName : LPCWSTR -> "char*"
# id : void* optional -> "void*"
# two : DWORD -> "dword"
# three : DWORD -> "dword"
# flags : SYM_FIND_ID_OPTION -> "dword"
# FoundFile : LPWSTR out -> "char*"
# callback : PFINDFILEINPATHCALLBACKW optional -> "void*"
# context : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。