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

SENSOR_PROPERTY_LIST

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

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

フィールド

フィールドサイズx64x86説明
AllocatedSizeInBytesDWORD4+0+0この構造体に割り当てられたバッファ全体のサイズをバイトで表す。
CountDWORD4+4+4List内の有効なプロパティキーの個数を表す。
ListPROPERTYKEY20+8+8PROPERTYKEYの可変長配列の先頭要素。

各言語での定義

#include <windows.h>

// PROPERTYKEY  (x64 20 / x86 20 バイト)
typedef struct PROPERTYKEY {
    GUID fmtid;
    DWORD pid;
} PROPERTYKEY;

// SENSOR_PROPERTY_LIST  (x64 28 / x86 28 バイト)
typedef struct SENSOR_PROPERTY_LIST {
    DWORD AllocatedSizeInBytes;
    DWORD Count;
    PROPERTYKEY List[1];
} SENSOR_PROPERTY_LIST;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PROPERTYKEY
{
    public Guid fmtid;
    public uint pid;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SENSOR_PROPERTY_LIST
{
    public uint AllocatedSizeInBytes;
    public uint Count;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public PROPERTYKEY[] List;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PROPERTYKEY
    Public fmtid As Guid
    Public pid As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SENSOR_PROPERTY_LIST
    Public AllocatedSizeInBytes As UInteger
    Public Count As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public List() As PROPERTYKEY
End Structure
import ctypes
from ctypes import wintypes

class PROPERTYKEY(ctypes.Structure):
    _fields_ = [
        ("fmtid", GUID),
        ("pid", wintypes.DWORD),
    ]

class SENSOR_PROPERTY_LIST(ctypes.Structure):
    _fields_ = [
        ("AllocatedSizeInBytes", wintypes.DWORD),
        ("Count", wintypes.DWORD),
        ("List", PROPERTYKEY * 1),
    ]
#[repr(C)]
pub struct PROPERTYKEY {
    pub fmtid: GUID,
    pub pid: u32,
}

#[repr(C)]
pub struct SENSOR_PROPERTY_LIST {
    pub AllocatedSizeInBytes: u32,
    pub Count: u32,
    pub List: [PROPERTYKEY; 1],
}
import "golang.org/x/sys/windows"

type PROPERTYKEY struct {
	fmtid windows.GUID
	pid uint32
}

type SENSOR_PROPERTY_LIST struct {
	AllocatedSizeInBytes uint32
	Count uint32
	List [1]PROPERTYKEY
}
type
  PROPERTYKEY = record
    fmtid: TGUID;
    pid: DWORD;
  end;

  SENSOR_PROPERTY_LIST = record
    AllocatedSizeInBytes: DWORD;
    Count: DWORD;
    List: array[0..0] of PROPERTYKEY;
  end;
const PROPERTYKEY = extern struct {
    fmtid: GUID,
    pid: u32,
};

const SENSOR_PROPERTY_LIST = extern struct {
    AllocatedSizeInBytes: u32,
    Count: u32,
    List: [1]PROPERTYKEY,
};
type
  PROPERTYKEY {.bycopy.} = object
    fmtid: GUID
    pid: uint32

  SENSOR_PROPERTY_LIST {.bycopy.} = object
    AllocatedSizeInBytes: uint32
    Count: uint32
    List: array[1, PROPERTYKEY]
struct PROPERTYKEY
{
    GUID fmtid;
    uint pid;
}

struct SENSOR_PROPERTY_LIST
{
    uint AllocatedSizeInBytes;
    uint Count;
    PROPERTYKEY[1] List;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SENSOR_PROPERTY_LIST サイズ: 28 バイト(x64)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; AllocatedSizeInBytes : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Count : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; List : PROPERTYKEY (+8, 20byte)  varptr(st)+8 を基点に操作(20byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
    #field int Data1
    #field short Data2
    #field short Data3
    #field byte Data4 8
#endstruct

#defstruct global PROPERTYKEY
    #field GUID fmtid
    #field int pid
#endstruct

#defstruct global SENSOR_PROPERTY_LIST
    #field int AllocatedSizeInBytes
    #field int Count
    #field PROPERTYKEY List 1
#endstruct

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