ホーム › Devices.SerialCommunication › SERIALCONFIG
SERIALCONFIG
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Size | DWORD | 4 | +0 | +0 | この構成構造体全体のサイズをバイトで表す。 |
| Version | WORD | 2 | +4 | +4 | 構成構造体のバージョン番号を表す。 |
| SubType | DWORD | 4 | +8 | +8 | シリアルプロバイダのサブタイプを示す値。 |
| ProvOffset | DWORD | 4 | +12 | +12 | ProviderDataまでのオフセットをバイトで表す。 |
| ProviderSize | DWORD | 4 | +16 | +16 | プロバイダ固有データのサイズをバイトで表す。 |
| ProviderData | WCHAR | 2 | +20 | +20 | プロバイダ固有の構成データを格納するワイド文字配列の先頭。 |
各言語での定義
#include <windows.h>
// SERIALCONFIG (x64 24 / x86 24 バイト)
typedef struct SERIALCONFIG {
DWORD Size;
WORD Version;
DWORD SubType;
DWORD ProvOffset;
DWORD ProviderSize;
WCHAR ProviderData[1];
} SERIALCONFIG;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERIALCONFIG
{
public uint Size;
public ushort Version;
public uint SubType;
public uint ProvOffset;
public uint ProviderSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)] public string ProviderData;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERIALCONFIG
Public Size As UInteger
Public Version As UShort
Public SubType As UInteger
Public ProvOffset As UInteger
Public ProviderSize As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)> Public ProviderData As String
End Structureimport ctypes
from ctypes import wintypes
class SERIALCONFIG(ctypes.Structure):
_fields_ = [
("Size", wintypes.DWORD),
("Version", ctypes.c_ushort),
("SubType", wintypes.DWORD),
("ProvOffset", wintypes.DWORD),
("ProviderSize", wintypes.DWORD),
("ProviderData", ctypes.c_wchar * 1),
]#[repr(C)]
pub struct SERIALCONFIG {
pub Size: u32,
pub Version: u16,
pub SubType: u32,
pub ProvOffset: u32,
pub ProviderSize: u32,
pub ProviderData: [u16; 1],
}import "golang.org/x/sys/windows"
type SERIALCONFIG struct {
Size uint32
Version uint16
SubType uint32
ProvOffset uint32
ProviderSize uint32
ProviderData [1]uint16
}type
SERIALCONFIG = record
Size: DWORD;
Version: Word;
SubType: DWORD;
ProvOffset: DWORD;
ProviderSize: DWORD;
ProviderData: array[0..0] of WideChar;
end;const SERIALCONFIG = extern struct {
Size: u32,
Version: u16,
SubType: u32,
ProvOffset: u32,
ProviderSize: u32,
ProviderData: [1]u16,
};type
SERIALCONFIG {.bycopy.} = object
Size: uint32
Version: uint16
SubType: uint32
ProvOffset: uint32
ProviderSize: uint32
ProviderData: array[1, uint16]struct SERIALCONFIG
{
uint Size;
ushort Version;
uint SubType;
uint ProvOffset;
uint ProviderSize;
wchar[1] ProviderData;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SERIALCONFIG サイズ: 24 バイト(x64)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; Size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Version : WORD (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; SubType : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; ProvOffset : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; ProviderSize : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ProviderData : WCHAR (+20, 2byte) varptr(st)+20 を基点に操作(2byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SERIALCONFIG
#field int Size
#field short Version
#field int SubType
#field int ProvOffset
#field int ProviderSize
#field wchar ProviderData 1
#endstruct
stdim st, SERIALCONFIG ; NSTRUCT 変数を確保
st->Size = 100
mes "Size=" + st->Size