Win32 API 日本語リファレンス
ホームSystem.Wmi › MI_Instance

MI_Instance

構造体
サイズx64: 64 バイト / x86: 32 バイト

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

フィールド

フィールドサイズx64x86説明
ftMI_InstanceFT*8/4+0+0インスタンス操作用関数テーブルへのポインタ。
classDeclMI_ClassDecl*8/4+8+4このインスタンスのクラス宣言へのポインタ。
serverNameWORD*8/4+16+8インスタンス取得元のサーバー名。NULL可。
nameSpaceWORD*8/4+24+12インスタンスの名前空間名。NULL可。
reservedINT_PTR32/16+32+16将来の拡張用の予約フィールド。

各言語での定義

#include <windows.h>

// MI_Instance  (x64 64 / x86 32 バイト)
typedef struct MI_Instance {
    MI_InstanceFT* ft;
    MI_ClassDecl* classDecl;
    WORD* serverName;
    WORD* nameSpace;
    INT_PTR reserved[4];
} MI_Instance;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MI_Instance
{
    public IntPtr ft;
    public IntPtr classDecl;
    public IntPtr serverName;
    public IntPtr nameSpace;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public IntPtr[] reserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MI_Instance
    Public ft As IntPtr
    Public classDecl As IntPtr
    Public serverName As IntPtr
    Public nameSpace As IntPtr
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public reserved() As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class MI_Instance(ctypes.Structure):
    _fields_ = [
        ("ft", ctypes.c_void_p),
        ("classDecl", ctypes.c_void_p),
        ("serverName", ctypes.c_void_p),
        ("nameSpace", ctypes.c_void_p),
        ("reserved", ctypes.c_ssize_t * 4),
    ]
#[repr(C)]
pub struct MI_Instance {
    pub ft: *mut core::ffi::c_void,
    pub classDecl: *mut core::ffi::c_void,
    pub serverName: *mut core::ffi::c_void,
    pub nameSpace: *mut core::ffi::c_void,
    pub reserved: [isize; 4],
}
import "golang.org/x/sys/windows"

type MI_Instance struct {
	ft uintptr
	classDecl uintptr
	serverName uintptr
	nameSpace uintptr
	reserved [4]uintptr
}
type
  MI_Instance = record
    ft: Pointer;
    classDecl: Pointer;
    serverName: Pointer;
    nameSpace: Pointer;
    reserved: array[0..3] of NativeInt;
  end;
const MI_Instance = extern struct {
    ft: ?*anyopaque,
    classDecl: ?*anyopaque,
    serverName: ?*anyopaque,
    nameSpace: ?*anyopaque,
    reserved: [4]isize,
};
type
  MI_Instance {.bycopy.} = object
    ft: pointer
    classDecl: pointer
    serverName: pointer
    nameSpace: pointer
    reserved: array[4, int]
struct MI_Instance
{
    void* ft;
    void* classDecl;
    void* serverName;
    void* nameSpace;
    ptrdiff_t[4] reserved;
}

HSP用 定義

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

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

stdim st, MI_Instance        ; NSTRUCT 変数を確保