Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › SetupFindNextMatchLineW

SetupFindNextMatchLineW

関数
INFで指定キーに一致する次の行を検索する(Unicode)。
DLLSETUPAPI.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupFindNextMatchLineW(
    INFCONTEXT* ContextIn,
    LPCWSTR Key,   // optional
    INFCONTEXT* ContextOut
);

パラメーター

名前方向
ContextInINFCONTEXT*in
KeyLPCWSTRinoptional
ContextOutINFCONTEXT*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetupFindNextMatchLineW(
    INFCONTEXT* ContextIn,
    LPCWSTR Key,   // optional
    INFCONTEXT* ContextOut
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupFindNextMatchLineW(
    IntPtr ContextIn,   // INFCONTEXT*
    [MarshalAs(UnmanagedType.LPWStr)] string Key,   // LPCWSTR optional
    IntPtr ContextOut   // INFCONTEXT* out
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupFindNextMatchLineW(
    ContextIn As IntPtr,   ' INFCONTEXT*
    <MarshalAs(UnmanagedType.LPWStr)> Key As String,   ' LPCWSTR optional
    ContextOut As IntPtr   ' INFCONTEXT* out
) As Boolean
End Function
' ContextIn : INFCONTEXT*
' Key : LPCWSTR optional
' ContextOut : INFCONTEXT* out
Declare PtrSafe Function SetupFindNextMatchLineW Lib "setupapi" ( _
    ByVal ContextIn As LongPtr, _
    ByVal Key As LongPtr, _
    ByVal ContextOut 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

SetupFindNextMatchLineW = ctypes.windll.setupapi.SetupFindNextMatchLineW
SetupFindNextMatchLineW.restype = wintypes.BOOL
SetupFindNextMatchLineW.argtypes = [
    ctypes.c_void_p,  # ContextIn : INFCONTEXT*
    wintypes.LPCWSTR,  # Key : LPCWSTR optional
    ctypes.c_void_p,  # ContextOut : INFCONTEXT* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupFindNextMatchLineW = setupapi.NewProc("SetupFindNextMatchLineW")
)

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