ホーム › Devices.SerialCommunication › SERENUM_PORT_DESC
SERENUM_PORT_DESC
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Size | DWORD | 4 | +0 | +0 | この記述子構造体のサイズをバイトで表す。 |
| PortHandle | void* | 8/4 | +8 | +4 | 対象シリアルポートを示すハンドルへのポインタ。 |
| PortAddress | LONGLONG | 8 | +16 | +8 | ポートのI/Oアドレスを表す。 |
| Reserved | WORD | 2 | +24 | +16 | 予約フィールド。0を設定する。 |
各言語での定義
#include <windows.h>
// SERENUM_PORT_DESC (x64 32 / x86 24 バイト)
typedef struct SERENUM_PORT_DESC {
DWORD Size;
void* PortHandle;
LONGLONG PortAddress;
WORD Reserved[1];
} SERENUM_PORT_DESC;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERENUM_PORT_DESC
{
public uint Size;
public IntPtr PortHandle;
public long PortAddress;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public ushort[] Reserved;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERENUM_PORT_DESC
Public Size As UInteger
Public PortHandle As IntPtr
Public PortAddress As Long
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Reserved() As UShort
End Structureimport ctypes
from ctypes import wintypes
class SERENUM_PORT_DESC(ctypes.Structure):
_fields_ = [
("Size", wintypes.DWORD),
("PortHandle", ctypes.c_void_p),
("PortAddress", ctypes.c_longlong),
("Reserved", ctypes.c_ushort * 1),
]#[repr(C)]
pub struct SERENUM_PORT_DESC {
pub Size: u32,
pub PortHandle: *mut core::ffi::c_void,
pub PortAddress: i64,
pub Reserved: [u16; 1],
}import "golang.org/x/sys/windows"
type SERENUM_PORT_DESC struct {
Size uint32
PortHandle uintptr
PortAddress int64
Reserved [1]uint16
}type
SERENUM_PORT_DESC = record
Size: DWORD;
PortHandle: Pointer;
PortAddress: Int64;
Reserved: array[0..0] of Word;
end;const SERENUM_PORT_DESC = extern struct {
Size: u32,
PortHandle: ?*anyopaque,
PortAddress: i64,
Reserved: [1]u16,
};type
SERENUM_PORT_DESC {.bycopy.} = object
Size: uint32
PortHandle: pointer
PortAddress: int64
Reserved: array[1, uint16]struct SERENUM_PORT_DESC
{
uint Size;
void* PortHandle;
long PortAddress;
ushort[1] Reserved;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SERENUM_PORT_DESC サイズ: 24 バイト(x86)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; Size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; PortHandle : void* (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; PortAddress : LONGLONG (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; Reserved : WORD (+16, 2byte) varptr(st)+16 を基点に操作(2byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SERENUM_PORT_DESC サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; Size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; PortHandle : void* (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; PortAddress : LONGLONG (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; Reserved : WORD (+24, 2byte) varptr(st)+24 を基点に操作(2byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SERENUM_PORT_DESC
#field int Size
#field intptr PortHandle
#field int64 PortAddress
#field short Reserved 1
#endstruct
stdim st, SERENUM_PORT_DESC ; NSTRUCT 変数を確保
st->Size = 100
mes "Size=" + st->Size