ホーム › Graphics.Printing › PORT_INFO_2A
PORT_INFO_2A
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| pPortName | LPSTR | 8/4 | +0 | +0 | ポート名(ANSI)へのポインタ。 |
| pMonitorName | LPSTR | 8/4 | +8 | +4 | このポートを監視するポートモニタ名(ANSI)へのポインタ。 |
| pDescription | LPSTR | 8/4 | +16 | +8 | ポートの説明文字列(ANSI)へのポインタ。 |
| fPortType | DWORD | 4 | +24 | +12 | ポートの種類を示すビットフラグ(PORT_TYPE_WRITE等)。 |
| Reserved | DWORD | 4 | +28 | +16 | 予約フィールド。0を設定する。 |
各言語での定義
#include <windows.h>
// PORT_INFO_2A (x64 32 / x86 20 バイト)
typedef struct PORT_INFO_2A {
LPSTR pPortName;
LPSTR pMonitorName;
LPSTR pDescription;
DWORD fPortType;
DWORD Reserved;
} PORT_INFO_2A;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PORT_INFO_2A
{
public IntPtr pPortName;
public IntPtr pMonitorName;
public IntPtr pDescription;
public uint fPortType;
public uint Reserved;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PORT_INFO_2A
Public pPortName As IntPtr
Public pMonitorName As IntPtr
Public pDescription As IntPtr
Public fPortType As UInteger
Public Reserved As UInteger
End Structureimport ctypes
from ctypes import wintypes
class PORT_INFO_2A(ctypes.Structure):
_fields_ = [
("pPortName", ctypes.c_void_p),
("pMonitorName", ctypes.c_void_p),
("pDescription", ctypes.c_void_p),
("fPortType", wintypes.DWORD),
("Reserved", wintypes.DWORD),
]#[repr(C)]
pub struct PORT_INFO_2A {
pub pPortName: *mut core::ffi::c_void,
pub pMonitorName: *mut core::ffi::c_void,
pub pDescription: *mut core::ffi::c_void,
pub fPortType: u32,
pub Reserved: u32,
}import "golang.org/x/sys/windows"
type PORT_INFO_2A struct {
pPortName uintptr
pMonitorName uintptr
pDescription uintptr
fPortType uint32
Reserved uint32
}type
PORT_INFO_2A = record
pPortName: Pointer;
pMonitorName: Pointer;
pDescription: Pointer;
fPortType: DWORD;
Reserved: DWORD;
end;const PORT_INFO_2A = extern struct {
pPortName: ?*anyopaque,
pMonitorName: ?*anyopaque,
pDescription: ?*anyopaque,
fPortType: u32,
Reserved: u32,
};type
PORT_INFO_2A {.bycopy.} = object
pPortName: pointer
pMonitorName: pointer
pDescription: pointer
fPortType: uint32
Reserved: uint32struct PORT_INFO_2A
{
void* pPortName;
void* pMonitorName;
void* pDescription;
uint fPortType;
uint Reserved;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PORT_INFO_2A サイズ: 20 バイト(x86)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; pPortName : LPSTR (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; pMonitorName : LPSTR (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; pDescription : LPSTR (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; fPortType : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; Reserved : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PORT_INFO_2A サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; pPortName : LPSTR (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; pMonitorName : LPSTR (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; pDescription : LPSTR (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; fPortType : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; Reserved : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PORT_INFO_2A
#field intptr pPortName
#field intptr pMonitorName
#field intptr pDescription
#field int fPortType
#field int Reserved
#endstruct
stdim st, PORT_INFO_2A ; NSTRUCT 変数を確保
st->fPortType = 100
mes "fPortType=" + st->fPortType