ホーム › 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 <MarshalAs(UnmanagedType.Bool)> 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)。const std = @import("std");
extern "setupapi" fn SetupGetIntField(
Context: [*c]INFCONTEXT, // INFCONTEXT*
FieldIndex: u32, // DWORD
IntegerValue: [*c]i32 // INT* out
) callconv(std.os.windows.WINAPI) i32;proc SetupGetIntField(
Context: ptr INFCONTEXT, # INFCONTEXT*
FieldIndex: uint32, # DWORD
IntegerValue: ptr int32 # INT* out
): int32 {.importc: "SetupGetIntField", stdcall, dynlib: "SETUPAPI.dll".}pragma(lib, "setupapi");
extern(Windows)
int SetupGetIntField(
INFCONTEXT* Context, // INFCONTEXT*
uint FieldIndex, // DWORD
int* IntegerValue // INT* out
);ccall((:SetupGetIntField, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{INFCONTEXT}, UInt32, Ptr{Int32}),
Context, FieldIndex, IntegerValue)
# Context : INFCONTEXT* -> Ptr{INFCONTEXT}
# FieldIndex : DWORD -> UInt32
# IntegerValue : INT* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupGetIntField(
void* Context,
uint32_t FieldIndex,
int32_t* IntegerValue);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupGetIntField(Context, FieldIndex, IntegerValue)
-- Context : INFCONTEXT*
-- FieldIndex : DWORD
-- IntegerValue : INT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupGetIntField = lib.func('__stdcall', 'SetupGetIntField', 'int32_t', ['void *', 'uint32_t', 'int32_t *']);
// SetupGetIntField(Context, FieldIndex, IntegerValue)
// Context : INFCONTEXT* -> 'void *'
// FieldIndex : DWORD -> 'uint32_t'
// IntegerValue : INT* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupGetIntField: { parameters: ["pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.SetupGetIntField(Context, FieldIndex, IntegerValue)
// Context : INFCONTEXT* -> "pointer"
// FieldIndex : DWORD -> "u32"
// IntegerValue : INT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupGetIntField(
void* Context,
uint32_t FieldIndex,
int32_t* IntegerValue);
C, "SETUPAPI.dll");
// $ffi->SetupGetIntField(Context, FieldIndex, IntegerValue);
// Context : INFCONTEXT*
// FieldIndex : DWORD
// IntegerValue : INT* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Setupapi extends StdCallLibrary {
Setupapi INSTANCE = Native.load("setupapi", Setupapi.class);
boolean SetupGetIntField(
Pointer Context, // INFCONTEXT*
int FieldIndex, // DWORD
IntByReference IntegerValue // INT* out
);
}@[Link("setupapi")]
lib LibSETUPAPI
fun SetupGetIntField = SetupGetIntField(
Context : INFCONTEXT*, # INFCONTEXT*
FieldIndex : UInt32, # DWORD
IntegerValue : Int32* # INT* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupGetIntFieldNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Int32>);
typedef SetupGetIntFieldDart = int Function(Pointer<Void>, int, Pointer<Int32>);
final SetupGetIntField = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupGetIntFieldNative, SetupGetIntFieldDart>('SetupGetIntField');
// Context : INFCONTEXT* -> Pointer<Void>
// FieldIndex : DWORD -> Uint32
// IntegerValue : INT* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupGetIntField(
Context: Pointer; // INFCONTEXT*
FieldIndex: DWORD; // DWORD
IntegerValue: Pointer // INT* out
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupGetIntField';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupGetIntField"
c_SetupGetIntField :: Ptr () -> Word32 -> Ptr Int32 -> IO CInt
-- Context : INFCONTEXT* -> Ptr ()
-- FieldIndex : DWORD -> Word32
-- IntegerValue : INT* out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupgetintfield =
foreign "SetupGetIntField"
((ptr void) @-> uint32_t @-> (ptr int32_t) @-> returning int32_t)
(* Context : INFCONTEXT* -> (ptr void) *)
(* FieldIndex : DWORD -> uint32_t *)
(* IntegerValue : INT* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupGetIntField" setup-get-int-field :convention :stdcall) :int32
(context :pointer) ; INFCONTEXT*
(field-index :uint32) ; DWORD
(integer-value :pointer)) ; INT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupGetIntField = Win32::API::More->new('SETUPAPI',
'BOOL SetupGetIntField(LPVOID Context, DWORD FieldIndex, LPVOID IntegerValue)');
# my $ret = $SetupGetIntField->Call($Context, $FieldIndex, $IntegerValue);
# Context : INFCONTEXT* -> LPVOID
# FieldIndex : DWORD -> DWORD
# IntegerValue : INT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型