Win32 API 日本語リファレンス
ホームGraphics.Printing › PORT_DATA_1

PORT_DATA_1

構造体
サイズx64: 964 バイト / x86: 964 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
sztPortNameWCHAR128+0+0ポート名を格納するUnicode文字配列。
dwVersionDWORD4+128+128構造体のバージョン番号。
dwProtocolDWORD4+132+132使用する印刷プロトコル(RAWまたはLPR)を示す値。
cbSizeDWORD4+136+136この構造体のサイズをバイト単位で指定する。
dwReservedDWORD4+140+140予約フィールド。0に設定する。
sztHostAddressWCHAR98+144+144プリンターのホストアドレスを格納するUnicode文字配列。
sztSNMPCommunityWCHAR66+242+242SNMPコミュニティ名を格納するUnicode文字配列。
dwDoubleSpoolDWORD4+308+308ダブルスプール(双方向スプール)を有効にするか示すフラグ。
sztQueueWCHAR66+312+312LPRプロトコル時のキュー名を格納するUnicode文字配列。
sztIPAddressWCHAR32+378+378プリンターのIPアドレスを格納するUnicode文字配列。
ReservedBYTE540+410+410予約バイト配列。
dwPortNumberDWORD4+952+952RAWプロトコル時のTCPポート番号。
dwSNMPEnabledDWORD4+956+956SNMPステータス監視を有効にするか示すフラグ。
dwSNMPDevIndexDWORD4+960+960SNMPデバイスインデックス番号。

各言語での定義

#include <windows.h>

// PORT_DATA_1  (x64 964 / x86 964 バイト)
typedef struct PORT_DATA_1 {
    WCHAR sztPortName[64];
    DWORD dwVersion;
    DWORD dwProtocol;
    DWORD cbSize;
    DWORD dwReserved;
    WCHAR sztHostAddress[49];
    WCHAR sztSNMPCommunity[33];
    DWORD dwDoubleSpool;
    WCHAR sztQueue[33];
    WCHAR sztIPAddress[16];
    BYTE Reserved[540];
    DWORD dwPortNumber;
    DWORD dwSNMPEnabled;
    DWORD dwSNMPDevIndex;
} PORT_DATA_1;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PORT_DATA_1
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string sztPortName;
    public uint dwVersion;
    public uint dwProtocol;
    public uint cbSize;
    public uint dwReserved;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 49)] public string sztHostAddress;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 33)] public string sztSNMPCommunity;
    public uint dwDoubleSpool;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 33)] public string sztQueue;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string sztIPAddress;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 540)] public byte[] Reserved;
    public uint dwPortNumber;
    public uint dwSNMPEnabled;
    public uint dwSNMPDevIndex;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PORT_DATA_1
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> Public sztPortName As String
    Public dwVersion As UInteger
    Public dwProtocol As UInteger
    Public cbSize As UInteger
    Public dwReserved As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=49)> Public sztHostAddress As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=33)> Public sztSNMPCommunity As String
    Public dwDoubleSpool As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=33)> Public sztQueue As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=16)> Public sztIPAddress As String
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=540)> Public Reserved() As Byte
    Public dwPortNumber As UInteger
    Public dwSNMPEnabled As UInteger
    Public dwSNMPDevIndex As UInteger
End Structure
import ctypes
from ctypes import wintypes

class PORT_DATA_1(ctypes.Structure):
    _fields_ = [
        ("sztPortName", ctypes.c_wchar * 64),
        ("dwVersion", wintypes.DWORD),
        ("dwProtocol", wintypes.DWORD),
        ("cbSize", wintypes.DWORD),
        ("dwReserved", wintypes.DWORD),
        ("sztHostAddress", ctypes.c_wchar * 49),
        ("sztSNMPCommunity", ctypes.c_wchar * 33),
        ("dwDoubleSpool", wintypes.DWORD),
        ("sztQueue", ctypes.c_wchar * 33),
        ("sztIPAddress", ctypes.c_wchar * 16),
        ("Reserved", ctypes.c_ubyte * 540),
        ("dwPortNumber", wintypes.DWORD),
        ("dwSNMPEnabled", wintypes.DWORD),
        ("dwSNMPDevIndex", wintypes.DWORD),
    ]
#[repr(C)]
pub struct PORT_DATA_1 {
    pub sztPortName: [u16; 64],
    pub dwVersion: u32,
    pub dwProtocol: u32,
    pub cbSize: u32,
    pub dwReserved: u32,
    pub sztHostAddress: [u16; 49],
    pub sztSNMPCommunity: [u16; 33],
    pub dwDoubleSpool: u32,
    pub sztQueue: [u16; 33],
    pub sztIPAddress: [u16; 16],
    pub Reserved: [u8; 540],
    pub dwPortNumber: u32,
    pub dwSNMPEnabled: u32,
    pub dwSNMPDevIndex: u32,
}
import "golang.org/x/sys/windows"

type PORT_DATA_1 struct {
	sztPortName [64]uint16
	dwVersion uint32
	dwProtocol uint32
	cbSize uint32
	dwReserved uint32
	sztHostAddress [49]uint16
	sztSNMPCommunity [33]uint16
	dwDoubleSpool uint32
	sztQueue [33]uint16
	sztIPAddress [16]uint16
	Reserved [540]byte
	dwPortNumber uint32
	dwSNMPEnabled uint32
	dwSNMPDevIndex uint32
}
type
  PORT_DATA_1 = record
    sztPortName: array[0..63] of WideChar;
    dwVersion: DWORD;
    dwProtocol: DWORD;
    cbSize: DWORD;
    dwReserved: DWORD;
    sztHostAddress: array[0..48] of WideChar;
    sztSNMPCommunity: array[0..32] of WideChar;
    dwDoubleSpool: DWORD;
    sztQueue: array[0..32] of WideChar;
    sztIPAddress: array[0..15] of WideChar;
    Reserved: array[0..539] of Byte;
    dwPortNumber: DWORD;
    dwSNMPEnabled: DWORD;
    dwSNMPDevIndex: DWORD;
  end;
const PORT_DATA_1 = extern struct {
    sztPortName: [64]u16,
    dwVersion: u32,
    dwProtocol: u32,
    cbSize: u32,
    dwReserved: u32,
    sztHostAddress: [49]u16,
    sztSNMPCommunity: [33]u16,
    dwDoubleSpool: u32,
    sztQueue: [33]u16,
    sztIPAddress: [16]u16,
    Reserved: [540]u8,
    dwPortNumber: u32,
    dwSNMPEnabled: u32,
    dwSNMPDevIndex: u32,
};
type
  PORT_DATA_1 {.bycopy.} = object
    sztPortName: array[64, uint16]
    dwVersion: uint32
    dwProtocol: uint32
    cbSize: uint32
    dwReserved: uint32
    sztHostAddress: array[49, uint16]
    sztSNMPCommunity: array[33, uint16]
    dwDoubleSpool: uint32
    sztQueue: array[33, uint16]
    sztIPAddress: array[16, uint16]
    Reserved: array[540, uint8]
    dwPortNumber: uint32
    dwSNMPEnabled: uint32
    dwSNMPDevIndex: uint32
struct PORT_DATA_1
{
    wchar[64] sztPortName;
    uint dwVersion;
    uint dwProtocol;
    uint cbSize;
    uint dwReserved;
    wchar[49] sztHostAddress;
    wchar[33] sztSNMPCommunity;
    uint dwDoubleSpool;
    wchar[33] sztQueue;
    wchar[16] sztIPAddress;
    ubyte[540] Reserved;
    uint dwPortNumber;
    uint dwSNMPEnabled;
    uint dwSNMPDevIndex;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PORT_DATA_1 サイズ: 964 バイト(x64)
dim st, 241    ; 4byte整数×241(構造体サイズ 964 / 4 切り上げ)
; sztPortName : WCHAR (+0, 128byte)  varptr(st)+0 を基点に操作(128byte:入れ子/配列)
; dwVersion : DWORD (+128, 4byte)  st.32 = 値  /  値 = st.32   (lpoke/lpeek も可)
; dwProtocol : DWORD (+132, 4byte)  st.33 = 値  /  値 = st.33   (lpoke/lpeek も可)
; cbSize : DWORD (+136, 4byte)  st.34 = 値  /  値 = st.34   (lpoke/lpeek も可)
; dwReserved : DWORD (+140, 4byte)  st.35 = 値  /  値 = st.35   (lpoke/lpeek も可)
; sztHostAddress : WCHAR (+144, 98byte)  varptr(st)+144 を基点に操作(98byte:入れ子/配列)
; sztSNMPCommunity : WCHAR (+242, 66byte)  varptr(st)+242 を基点に操作(66byte:入れ子/配列)
; dwDoubleSpool : DWORD (+308, 4byte)  st.77 = 値  /  値 = st.77   (lpoke/lpeek も可)
; sztQueue : WCHAR (+312, 66byte)  varptr(st)+312 を基点に操作(66byte:入れ子/配列)
; sztIPAddress : WCHAR (+378, 32byte)  varptr(st)+378 を基点に操作(32byte:入れ子/配列)
; Reserved : BYTE (+410, 540byte)  varptr(st)+410 を基点に操作(540byte:入れ子/配列)
; dwPortNumber : DWORD (+952, 4byte)  st.238 = 値  /  値 = st.238   (lpoke/lpeek も可)
; dwSNMPEnabled : DWORD (+956, 4byte)  st.239 = 値  /  値 = st.239   (lpoke/lpeek も可)
; dwSNMPDevIndex : DWORD (+960, 4byte)  st.240 = 値  /  値 = st.240   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PORT_DATA_1
    #field wchar sztPortName 64
    #field int dwVersion
    #field int dwProtocol
    #field int cbSize
    #field int dwReserved
    #field wchar sztHostAddress 49
    #field wchar sztSNMPCommunity 33
    #field int dwDoubleSpool
    #field wchar sztQueue 33
    #field wchar sztIPAddress 16
    #field byte Reserved 540
    #field int dwPortNumber
    #field int dwSNMPEnabled
    #field int dwSNMPDevIndex
#endstruct

stdim st, PORT_DATA_1        ; NSTRUCT 変数を確保
st->dwVersion = 100
mes "dwVersion=" + st->dwVersion