ホーム › Devices.DeviceAndDriverInstallation › SetupFindNextMatchLineA
SetupFindNextMatchLineA
関数INFで指定キーに一致する次の行を検索する(ANSI)。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupFindNextMatchLineA(
INFCONTEXT* ContextIn,
LPCSTR Key, // optional
INFCONTEXT* ContextOut
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ContextIn | INFCONTEXT* | in |
| Key | LPCSTR | inoptional |
| ContextOut | INFCONTEXT* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupFindNextMatchLineA(
INFCONTEXT* ContextIn,
LPCSTR Key, // optional
INFCONTEXT* ContextOut
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupFindNextMatchLineA(
IntPtr ContextIn, // INFCONTEXT*
[MarshalAs(UnmanagedType.LPStr)] string Key, // LPCSTR optional
IntPtr ContextOut // INFCONTEXT* out
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupFindNextMatchLineA(
ContextIn As IntPtr, ' INFCONTEXT*
<MarshalAs(UnmanagedType.LPStr)> Key As String, ' LPCSTR optional
ContextOut As IntPtr ' INFCONTEXT* out
) As Boolean
End Function' ContextIn : INFCONTEXT*
' Key : LPCSTR optional
' ContextOut : INFCONTEXT* out
Declare PtrSafe Function SetupFindNextMatchLineA Lib "setupapi" ( _
ByVal ContextIn As LongPtr, _
ByVal Key As String, _
ByVal ContextOut As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupFindNextMatchLineA = ctypes.windll.setupapi.SetupFindNextMatchLineA
SetupFindNextMatchLineA.restype = wintypes.BOOL
SetupFindNextMatchLineA.argtypes = [
ctypes.c_void_p, # ContextIn : INFCONTEXT*
wintypes.LPCSTR, # Key : LPCSTR 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')
SetupFindNextMatchLineA = Fiddle::Function.new(
lib['SetupFindNextMatchLineA'],
[
Fiddle::TYPE_VOIDP, # ContextIn : INFCONTEXT*
Fiddle::TYPE_VOIDP, # Key : LPCSTR optional
Fiddle::TYPE_VOIDP, # ContextOut : INFCONTEXT* out
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupFindNextMatchLineA(
ContextIn: *mut INFCONTEXT, // INFCONTEXT*
Key: *const u8, // LPCSTR 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.Ansi, SetLastError = true)]
public static extern bool SetupFindNextMatchLineA(IntPtr ContextIn, [MarshalAs(UnmanagedType.LPStr)] string Key, IntPtr ContextOut);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupFindNextMatchLineA' -Namespace Win32 -PassThru
# $api::SetupFindNextMatchLineA(ContextIn, Key, ContextOut)#uselib "SETUPAPI.dll"
#func global SetupFindNextMatchLineA "SetupFindNextMatchLineA" sptr, sptr, sptr
; SetupFindNextMatchLineA varptr(ContextIn), Key, varptr(ContextOut) ; 戻り値は stat
; ContextIn : INFCONTEXT* -> "sptr"
; Key : LPCSTR optional -> "sptr"
; ContextOut : INFCONTEXT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupFindNextMatchLineA "SetupFindNextMatchLineA" var, str, var ; res = SetupFindNextMatchLineA(ContextIn, Key, ContextOut) ; ContextIn : INFCONTEXT* -> "var" ; Key : LPCSTR optional -> "str" ; ContextOut : INFCONTEXT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupFindNextMatchLineA "SetupFindNextMatchLineA" sptr, str, sptr ; res = SetupFindNextMatchLineA(varptr(ContextIn), Key, varptr(ContextOut)) ; ContextIn : INFCONTEXT* -> "sptr" ; Key : LPCSTR optional -> "str" ; ContextOut : INFCONTEXT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupFindNextMatchLineA(INFCONTEXT* ContextIn, LPCSTR Key, INFCONTEXT* ContextOut) #uselib "SETUPAPI.dll" #cfunc global SetupFindNextMatchLineA "SetupFindNextMatchLineA" var, str, var ; res = SetupFindNextMatchLineA(ContextIn, Key, ContextOut) ; ContextIn : INFCONTEXT* -> "var" ; Key : LPCSTR optional -> "str" ; ContextOut : INFCONTEXT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupFindNextMatchLineA(INFCONTEXT* ContextIn, LPCSTR Key, INFCONTEXT* ContextOut) #uselib "SETUPAPI.dll" #cfunc global SetupFindNextMatchLineA "SetupFindNextMatchLineA" intptr, str, intptr ; res = SetupFindNextMatchLineA(varptr(ContextIn), Key, varptr(ContextOut)) ; ContextIn : INFCONTEXT* -> "intptr" ; Key : LPCSTR optional -> "str" ; ContextOut : INFCONTEXT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupFindNextMatchLineA = setupapi.NewProc("SetupFindNextMatchLineA")
)
// ContextIn (INFCONTEXT*), Key (LPCSTR optional), ContextOut (INFCONTEXT* out)
r1, _, err := procSetupFindNextMatchLineA.Call(
uintptr(ContextIn),
uintptr(unsafe.Pointer(windows.BytePtrFromString(Key))),
uintptr(ContextOut),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupFindNextMatchLineA(
ContextIn: Pointer; // INFCONTEXT*
Key: PAnsiChar; // LPCSTR optional
ContextOut: Pointer // INFCONTEXT* out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupFindNextMatchLineA';result := DllCall("SETUPAPI\SetupFindNextMatchLineA"
, "Ptr", ContextIn ; INFCONTEXT*
, "AStr", Key ; LPCSTR optional
, "Ptr", ContextOut ; INFCONTEXT* out
, "Int") ; return: BOOL●SetupFindNextMatchLineA(ContextIn, Key, ContextOut) = DLL("SETUPAPI.dll", "bool SetupFindNextMatchLineA(void*, char*, void*)")
# 呼び出し: SetupFindNextMatchLineA(ContextIn, Key, ContextOut)
# ContextIn : INFCONTEXT* -> "void*"
# Key : LPCSTR optional -> "char*"
# ContextOut : INFCONTEXT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。