Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › INFCONTEXT

INFCONTEXT

構造体
サイズx64: 24 バイト / x86: 16 バイトパッキング1

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
Infvoid*8/4+0+0INFファイル全体を表す内部ハンドルへのポインタ。SetupAPIが管理する。
CurrentInfvoid*8/4+8+4現在対象としているINF(付加INFを含む)への内部ポインタ。
SectionDWORD4+16+8INF内のセクションを示す内部インデックス値。
LineDWORD4+20+12セクション内の行を示す内部インデックス値。

各言語での定義

#include <windows.h>

// INFCONTEXT  (x64 24 / x86 16 バイト)
#pragma pack(push, 1)
typedef struct INFCONTEXT {
    void* Inf;
    void* CurrentInf;
    DWORD Section;
    DWORD Line;
} INFCONTEXT;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct INFCONTEXT
{
    public IntPtr Inf;
    public IntPtr CurrentInf;
    public uint Section;
    public uint Line;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure INFCONTEXT
    Public Inf As IntPtr
    Public CurrentInf As IntPtr
    Public Section As UInteger
    Public Line As UInteger
End Structure
import ctypes
from ctypes import wintypes

class INFCONTEXT(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("Inf", ctypes.c_void_p),
        ("CurrentInf", ctypes.c_void_p),
        ("Section", wintypes.DWORD),
        ("Line", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct INFCONTEXT {
    pub Inf: *mut core::ffi::c_void,
    pub CurrentInf: *mut core::ffi::c_void,
    pub Section: u32,
    pub Line: u32,
}
import "golang.org/x/sys/windows"

type INFCONTEXT struct {
	Inf uintptr
	CurrentInf uintptr
	Section uint32
	Line uint32
}
type
  INFCONTEXT = packed record
    Inf: Pointer;
    CurrentInf: Pointer;
    Section: DWORD;
    Line: DWORD;
  end;
const INFCONTEXT = extern struct {
    Inf: ?*anyopaque,
    CurrentInf: ?*anyopaque,
    Section: u32,
    Line: u32,
};
type
  INFCONTEXT {.packed.} = object
    Inf: pointer
    CurrentInf: pointer
    Section: uint32
    Line: uint32
align(1)
struct INFCONTEXT
{
    void* Inf;
    void* CurrentInf;
    uint Section;
    uint Line;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; INFCONTEXT サイズ: 16 バイト(x86)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; Inf : void* (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; CurrentInf : void* (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Section : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Line : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; INFCONTEXT サイズ: 24 バイト(x64)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; Inf : void* (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; CurrentInf : void* (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; Section : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; Line : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global INFCONTEXT, pack=1
    #field intptr Inf
    #field intptr CurrentInf
    #field int Section
    #field int Line
#endstruct

stdim st, INFCONTEXT        ; NSTRUCT 変数を確保
st->Section = 100
mes "Section=" + st->Section