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