ホーム › Devices.Display › Adapters
Adapters
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| numAdapters | INT | 4 | +0 | +0 | システム内のアダプター総数。adapter配列の要素数。 |
| adapter | Adapter | 272 | +4 | +4 | Adapter構造体の配列(可変長)。各表示アダプター情報を保持する。 |
各言語での定義
#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;
// Adapters (x64 276 / x86 276 バイト)
typedef struct Adapters {
INT numAdapters;
Adapter adapter[1];
} Adapters;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;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct Adapters
{
public int numAdapters;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public Adapter[] adapter;
}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 Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure Adapters
Public numAdapters As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public adapter() As Adapter
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),
]
class Adapters(ctypes.Structure):
_fields_ = [
("numAdapters", ctypes.c_int),
("adapter", Adapter * 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],
}
#[repr(C)]
pub struct Adapters {
pub numAdapters: i32,
pub adapter: [Adapter; 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 Adapters struct {
numAdapters int32
adapter [1]Adapter
}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;
Adapters = record
numAdapters: Integer;
adapter: array[0..0] of Adapter;
end;const Sources = extern struct {
sourceId: u32,
numTargets: i32,
aTargets: [1]u32,
};
const Adapter = extern struct {
AdapterName: [128]u16,
numSources: i32,
sources: [1]Sources,
};
const Adapters = extern struct {
numAdapters: i32,
adapter: [1]Adapter,
};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]
Adapters {.bycopy.} = object
numAdapters: int32
adapter: array[1, Adapter]struct Sources
{
uint sourceId;
int numTargets;
uint[1] aTargets;
}
struct Adapter
{
wchar[128] AdapterName;
int numSources;
Sources[1] sources;
}
struct Adapters
{
int numAdapters;
Adapter[1] adapter;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; Adapters サイズ: 276 バイト(x64)
dim st, 69 ; 4byte整数×69(構造体サイズ 276 / 4 切り上げ)
; numAdapters : INT (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; adapter : Adapter (+4, 272byte) varptr(st)+4 を基点に操作(272byte:入れ子/配列)
; ※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
#defstruct global Adapters
#field int numAdapters
#field Adapter adapter 1
#endstruct
stdim st, Adapters ; NSTRUCT 変数を確保
st->numAdapters = 100
mes "numAdapters=" + st->numAdapters