Win32 API 日本語リファレンス
ホームNetworkManagement.QoS › IDPE_ATTR

IDPE_ATTR

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

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

フィールド

フィールドサイズx64x86説明
PeAttribLengthWORD2+0+0ポリシー要素属性のバイト長。
PeAttribTypeBYTE1+2+2ポリシー要素属性の主タイプを示すバイト値。
PeAttribSubTypeBYTE1+3+3ポリシー要素属性のサブタイプを示すバイト値。
PeAttribValueBYTE4+4+4属性値データの先頭バイト。可変長配列の起点となる。

各言語での定義

#include <windows.h>

// IDPE_ATTR  (x64 8 / x86 8 バイト)
typedef struct IDPE_ATTR {
    WORD PeAttribLength;
    BYTE PeAttribType;
    BYTE PeAttribSubType;
    BYTE PeAttribValue[4];
} IDPE_ATTR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IDPE_ATTR
{
    public ushort PeAttribLength;
    public byte PeAttribType;
    public byte PeAttribSubType;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] PeAttribValue;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IDPE_ATTR
    Public PeAttribLength As UShort
    Public PeAttribType As Byte
    Public PeAttribSubType As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public PeAttribValue() As Byte
End Structure
import ctypes
from ctypes import wintypes

class IDPE_ATTR(ctypes.Structure):
    _fields_ = [
        ("PeAttribLength", ctypes.c_ushort),
        ("PeAttribType", ctypes.c_ubyte),
        ("PeAttribSubType", ctypes.c_ubyte),
        ("PeAttribValue", ctypes.c_ubyte * 4),
    ]
#[repr(C)]
pub struct IDPE_ATTR {
    pub PeAttribLength: u16,
    pub PeAttribType: u8,
    pub PeAttribSubType: u8,
    pub PeAttribValue: [u8; 4],
}
import "golang.org/x/sys/windows"

type IDPE_ATTR struct {
	PeAttribLength uint16
	PeAttribType byte
	PeAttribSubType byte
	PeAttribValue [4]byte
}
type
  IDPE_ATTR = record
    PeAttribLength: Word;
    PeAttribType: Byte;
    PeAttribSubType: Byte;
    PeAttribValue: array[0..3] of Byte;
  end;
const IDPE_ATTR = extern struct {
    PeAttribLength: u16,
    PeAttribType: u8,
    PeAttribSubType: u8,
    PeAttribValue: [4]u8,
};
type
  IDPE_ATTR {.bycopy.} = object
    PeAttribLength: uint16
    PeAttribType: uint8
    PeAttribSubType: uint8
    PeAttribValue: array[4, uint8]
struct IDPE_ATTR
{
    ushort PeAttribLength;
    ubyte PeAttribType;
    ubyte PeAttribSubType;
    ubyte[4] PeAttribValue;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IDPE_ATTR サイズ: 8 バイト(x64)
dim st, 2    ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; PeAttribLength : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; PeAttribType : BYTE (+2, 1byte)  poke st,2,値  /  値 = peek(st,2)
; PeAttribSubType : BYTE (+3, 1byte)  poke st,3,値  /  値 = peek(st,3)
; PeAttribValue : BYTE (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IDPE_ATTR
    #field short PeAttribLength
    #field byte PeAttribType
    #field byte PeAttribSubType
    #field byte PeAttribValue 4
#endstruct

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