ホーム › Devices.Display › Adapter
Adapter
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| AdapterName | WCHAR | 256 | +0 | +0 | ディスプレイアダプターの名称を表すワイド文字列。 |
| numSources | INT | 4 | +256 | +256 | このアダプターが持つソース数。sources配列の要素数。 |
| sources | Sources | 12 | +260 | +260 | アダブターに属するSources構造体の配列(可変長)。 |
各言語での定義
#include <windows.h>
// Sources (x64 12 / x86 12 バイト)
typedef struct Sources {
DWORD sourceId;
INT numTargets;
DWORD aTargets[1];
} Sources;
// Adapter (x64 272 / x86 272 バイト)
typedef struct Adapter {
WCHAR AdapterName[128];
INT numSources;
Sources sources[1];
} Adapter;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct Sources
{
public uint sourceId;
public int numTargets;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public uint[] aTargets;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct Adapter
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string AdapterName;
public int numSources;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public Sources[] sources;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure Sources
Public sourceId As UInteger
Public numTargets As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public aTargets() As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure Adapter
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public AdapterName As String
Public numSources As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public sources() As Sources
End Structureimport ctypes
from ctypes import wintypes
class Sources(ctypes.Structure):
_fields_ = [
("sourceId", wintypes.DWORD),
("numTargets", ctypes.c_int),
("aTargets", wintypes.DWORD * 1),
]
class Adapter(ctypes.Structure):
_fields_ = [
("AdapterName", ctypes.c_wchar * 128),
("numSources", ctypes.c_int),
("sources", Sources * 1),
]#[repr(C)]
pub struct Sources {
pub sourceId: u32,
pub numTargets: i32,
pub aTargets: [u32; 1],
}
#[repr(C)]
pub struct Adapter {
pub AdapterName: [u16; 128],
pub numSources: i32,
pub sources: [Sources; 1],
}import "golang.org/x/sys/windows"
type Sources struct {
sourceId uint32
numTargets int32
aTargets [1]uint32
}
type Adapter struct {
AdapterName [128]uint16
numSources int32
sources [1]Sources
}type
Sources = record
sourceId: DWORD;
numTargets: Integer;
aTargets: array[0..0] of DWORD;
end;
Adapter = record
AdapterName: array[0..127] of WideChar;
numSources: Integer;
sources: array[0..0] of Sources;
end;const Sources = extern struct {
sourceId: u32,
numTargets: i32,
aTargets: [1]u32,
};
const Adapter = extern struct {
AdapterName: [128]u16,
numSources: i32,
sources: [1]Sources,
};type
Sources {.bycopy.} = object
sourceId: uint32
numTargets: int32
aTargets: array[1, uint32]
Adapter {.bycopy.} = object
AdapterName: array[128, uint16]
numSources: int32
sources: array[1, Sources]struct Sources
{
uint sourceId;
int numTargets;
uint[1] aTargets;
}
struct Adapter
{
wchar[128] AdapterName;
int numSources;
Sources[1] sources;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; Adapter サイズ: 272 バイト(x64)
dim st, 68 ; 4byte整数×68(構造体サイズ 272 / 4 切り上げ)
; AdapterName : WCHAR (+0, 256byte) varptr(st)+0 を基点に操作(256byte:入れ子/配列)
; numSources : INT (+256, 4byte) st.64 = 値 / 値 = st.64 (lpoke/lpeek も可)
; sources : Sources (+260, 12byte) varptr(st)+260 を基点に操作(12byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global Sources
#field int sourceId
#field int numTargets
#field int aTargets 1
#endstruct
#defstruct global Adapter
#field wchar AdapterName 128
#field int numSources
#field Sources sources 1
#endstruct
stdim st, Adapter ; NSTRUCT 変数を確保
st->numSources = 100
mes "numSources=" + st->numSources