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