ホーム › Devices.DeviceAndDriverInstallation › SetupGetIntField
SetupGetIntField
関数INF行の指定フィールドの整数値を取得する。
シグネチャ
// SETUPAPI.dll
#include <windows.h>
BOOL SetupGetIntField(
INFCONTEXT* Context,
DWORD FieldIndex,
INT* IntegerValue
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Context | INFCONTEXT* | in | 対象行を示すINFCONTEXT構造体へのポインタ。 |
| FieldIndex | DWORD | in | 整数として取得するフィールドのインデックス(0起点)。 |
| IntegerValue | INT* | out | 解析した整数値を受け取る出力ポインタ。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll
#include <windows.h>
BOOL SetupGetIntField(
INFCONTEXT* Context,
DWORD FieldIndex,
INT* IntegerValue
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetupGetIntField(
IntPtr Context, // INFCONTEXT*
uint FieldIndex, // DWORD
out int IntegerValue // INT* out
);<DllImport("SETUPAPI.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupGetIntField(
Context As IntPtr, ' INFCONTEXT*
FieldIndex As UInteger, ' DWORD
<Out> ByRef IntegerValue As Integer ' INT* out
) As Boolean
End Function' Context : INFCONTEXT*
' FieldIndex : DWORD
' IntegerValue : INT* out
Declare PtrSafe Function SetupGetIntField Lib "setupapi" ( _
ByVal Context As LongPtr, _
ByVal FieldIndex As Long, _
ByRef IntegerValue As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupGetIntField = ctypes.windll.setupapi.SetupGetIntField
SetupGetIntField.restype = wintypes.BOOL
SetupGetIntField.argtypes = [
ctypes.c_void_p, # Context : INFCONTEXT*
wintypes.DWORD, # FieldIndex : DWORD
ctypes.POINTER(ctypes.c_int), # IntegerValue : INT* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupGetIntField = Fiddle::Function.new(
lib['SetupGetIntField'],
[
Fiddle::TYPE_VOIDP, # Context : INFCONTEXT*
-Fiddle::TYPE_INT, # FieldIndex : DWORD
Fiddle::TYPE_VOIDP, # IntegerValue : INT* out
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupGetIntField(
Context: *mut INFCONTEXT, // INFCONTEXT*
FieldIndex: u32, // DWORD
IntegerValue: *mut i32 // INT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", SetLastError = true)]
public static extern bool SetupGetIntField(IntPtr Context, uint FieldIndex, out int IntegerValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupGetIntField' -Namespace Win32 -PassThru
# $api::SetupGetIntField(Context, FieldIndex, IntegerValue)#uselib "SETUPAPI.dll"
#func global SetupGetIntField "SetupGetIntField" sptr, sptr, sptr
; SetupGetIntField varptr(Context), FieldIndex, varptr(IntegerValue) ; 戻り値は stat
; Context : INFCONTEXT* -> "sptr"
; FieldIndex : DWORD -> "sptr"
; IntegerValue : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupGetIntField "SetupGetIntField" var, int, var ; res = SetupGetIntField(Context, FieldIndex, IntegerValue) ; Context : INFCONTEXT* -> "var" ; FieldIndex : DWORD -> "int" ; IntegerValue : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupGetIntField "SetupGetIntField" sptr, int, sptr ; res = SetupGetIntField(varptr(Context), FieldIndex, varptr(IntegerValue)) ; Context : INFCONTEXT* -> "sptr" ; FieldIndex : DWORD -> "int" ; IntegerValue : INT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupGetIntField(INFCONTEXT* Context, DWORD FieldIndex, INT* IntegerValue) #uselib "SETUPAPI.dll" #cfunc global SetupGetIntField "SetupGetIntField" var, int, var ; res = SetupGetIntField(Context, FieldIndex, IntegerValue) ; Context : INFCONTEXT* -> "var" ; FieldIndex : DWORD -> "int" ; IntegerValue : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupGetIntField(INFCONTEXT* Context, DWORD FieldIndex, INT* IntegerValue) #uselib "SETUPAPI.dll" #cfunc global SetupGetIntField "SetupGetIntField" intptr, int, intptr ; res = SetupGetIntField(varptr(Context), FieldIndex, varptr(IntegerValue)) ; Context : INFCONTEXT* -> "intptr" ; FieldIndex : DWORD -> "int" ; IntegerValue : INT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupGetIntField = setupapi.NewProc("SetupGetIntField")
)
// Context (INFCONTEXT*), FieldIndex (DWORD), IntegerValue (INT* out)
r1, _, err := procSetupGetIntField.Call(
uintptr(Context),
uintptr(FieldIndex),
uintptr(IntegerValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupGetIntField(
Context: Pointer; // INFCONTEXT*
FieldIndex: DWORD; // DWORD
IntegerValue: Pointer // INT* out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupGetIntField';result := DllCall("SETUPAPI\SetupGetIntField"
, "Ptr", Context ; INFCONTEXT*
, "UInt", FieldIndex ; DWORD
, "Ptr", IntegerValue ; INT* out
, "Int") ; return: BOOL●SetupGetIntField(Context, FieldIndex, IntegerValue) = DLL("SETUPAPI.dll", "bool SetupGetIntField(void*, dword, void*)")
# 呼び出し: SetupGetIntField(Context, FieldIndex, IntegerValue)
# Context : INFCONTEXT* -> "void*"
# FieldIndex : DWORD -> "dword"
# IntegerValue : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。