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

FindDebugInfoFileExW

関数
コールバック付きでデバッグ情報ファイルを検索する拡張版である。
DLLdbghelp.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり

シグネチャ

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

HANDLE FindDebugInfoFileExW(
    LPCWSTR FileName,
    LPCWSTR SymbolPath,
    LPWSTR DebugFilePath,
    PFIND_DEBUG_FILE_CALLBACKW Callback,   // optional
    void* CallerData   // optional
);

パラメーター

名前方向
FileNameLPCWSTRin
SymbolPathLPCWSTRin
DebugFilePathLPWSTRout
CallbackPFIND_DEBUG_FILE_CALLBACKWinoptional
CallerDatavoid*inoptional

戻り値の型: HANDLE

各言語での呼び出し定義

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

HANDLE FindDebugInfoFileExW(
    LPCWSTR FileName,
    LPCWSTR SymbolPath,
    LPWSTR DebugFilePath,
    PFIND_DEBUG_FILE_CALLBACKW Callback,   // optional
    void* CallerData   // optional
);
[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr FindDebugInfoFileExW(
    [MarshalAs(UnmanagedType.LPWStr)] string FileName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string SymbolPath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder DebugFilePath,   // LPWSTR out
    IntPtr Callback,   // PFIND_DEBUG_FILE_CALLBACKW optional
    IntPtr CallerData   // void* optional
);
<DllImport("dbghelp.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FindDebugInfoFileExW(
    <MarshalAs(UnmanagedType.LPWStr)> FileName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> SymbolPath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> DebugFilePath As System.Text.StringBuilder,   ' LPWSTR out
    Callback As IntPtr,   ' PFIND_DEBUG_FILE_CALLBACKW optional
    CallerData As IntPtr   ' void* optional
) As IntPtr
End Function
' FileName : LPCWSTR
' SymbolPath : LPCWSTR
' DebugFilePath : LPWSTR out
' Callback : PFIND_DEBUG_FILE_CALLBACKW optional
' CallerData : void* optional
Declare PtrSafe Function FindDebugInfoFileExW Lib "dbghelp" ( _
    ByVal FileName As LongPtr, _
    ByVal SymbolPath As LongPtr, _
    ByVal DebugFilePath As LongPtr, _
    ByVal Callback As LongPtr, _
    ByVal CallerData As LongPtr) 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

FindDebugInfoFileExW = ctypes.windll.dbghelp.FindDebugInfoFileExW
FindDebugInfoFileExW.restype = ctypes.c_void_p
FindDebugInfoFileExW.argtypes = [
    wintypes.LPCWSTR,  # FileName : LPCWSTR
    wintypes.LPCWSTR,  # SymbolPath : LPCWSTR
    wintypes.LPWSTR,  # DebugFilePath : LPWSTR out
    ctypes.c_void_p,  # Callback : PFIND_DEBUG_FILE_CALLBACKW optional
    ctypes.POINTER(None),  # CallerData : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
	procFindDebugInfoFileExW = dbghelp.NewProc("FindDebugInfoFileExW")
)

// FileName (LPCWSTR), SymbolPath (LPCWSTR), DebugFilePath (LPWSTR out), Callback (PFIND_DEBUG_FILE_CALLBACKW optional), CallerData (void* optional)
r1, _, err := procFindDebugInfoFileExW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FileName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SymbolPath))),
	uintptr(DebugFilePath),
	uintptr(Callback),
	uintptr(CallerData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HANDLE
function FindDebugInfoFileExW(
  FileName: PWideChar;   // LPCWSTR
  SymbolPath: PWideChar;   // LPCWSTR
  DebugFilePath: PWideChar;   // LPWSTR out
  Callback: Pointer;   // PFIND_DEBUG_FILE_CALLBACKW optional
  CallerData: Pointer   // void* optional
): THandle; stdcall;
  external 'dbghelp.dll' name 'FindDebugInfoFileExW';
result := DllCall("dbghelp\FindDebugInfoFileExW"
    , "WStr", FileName   ; LPCWSTR
    , "WStr", SymbolPath   ; LPCWSTR
    , "Ptr", DebugFilePath   ; LPWSTR out
    , "Ptr", Callback   ; PFIND_DEBUG_FILE_CALLBACKW optional
    , "Ptr", CallerData   ; void* optional
    , "Ptr")   ; return: HANDLE
●FindDebugInfoFileExW(FileName, SymbolPath, DebugFilePath, Callback, CallerData) = DLL("dbghelp.dll", "void* FindDebugInfoFileExW(char*, char*, char*, void*, void*)")
# 呼び出し: FindDebugInfoFileExW(FileName, SymbolPath, DebugFilePath, Callback, CallerData)
# FileName : LPCWSTR -> "char*"
# SymbolPath : LPCWSTR -> "char*"
# DebugFilePath : LPWSTR out -> "char*"
# Callback : PFIND_DEBUG_FILE_CALLBACKW optional -> "void*"
# CallerData : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。