Win32 API 日本語リファレンス
ホームNetworking.WinSock › WINDOWS_DEVICELIST

WINDOWS_DEVICELIST

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

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

フィールド

フィールドサイズx64x86説明
numDeviceDWORD4+0+0Device配列に含まれるデバイス数である。
DeviceWINDOWS_IRDA_DEVICE_INFO29+4+4検出されたIrDAデバイス情報(WINDOWS_IRDA_DEVICE_INFO)配列である。

各言語での定義

#include <windows.h>

// WINDOWS_IRDA_DEVICE_INFO  (x64 29 / x86 29 バイト)
typedef struct WINDOWS_IRDA_DEVICE_INFO {
    BYTE irdaDeviceID[4];
    CHAR irdaDeviceName[22];
    BYTE irdaDeviceHints1;
    BYTE irdaDeviceHints2;
    BYTE irdaCharSet;
} WINDOWS_IRDA_DEVICE_INFO;

// WINDOWS_DEVICELIST  (x64 36 / x86 36 バイト)
typedef struct WINDOWS_DEVICELIST {
    DWORD numDevice;
    WINDOWS_IRDA_DEVICE_INFO Device[1];
} WINDOWS_DEVICELIST;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WINDOWS_IRDA_DEVICE_INFO
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] irdaDeviceID;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)] public sbyte[] irdaDeviceName;
    public byte irdaDeviceHints1;
    public byte irdaDeviceHints2;
    public byte irdaCharSet;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WINDOWS_DEVICELIST
{
    public uint numDevice;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public WINDOWS_IRDA_DEVICE_INFO[] Device;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WINDOWS_IRDA_DEVICE_INFO
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public irdaDeviceID() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=22)> Public irdaDeviceName() As SByte
    Public irdaDeviceHints1 As Byte
    Public irdaDeviceHints2 As Byte
    Public irdaCharSet As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WINDOWS_DEVICELIST
    Public numDevice As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Device() As WINDOWS_IRDA_DEVICE_INFO
End Structure
import ctypes
from ctypes import wintypes

class WINDOWS_IRDA_DEVICE_INFO(ctypes.Structure):
    _fields_ = [
        ("irdaDeviceID", ctypes.c_ubyte * 4),
        ("irdaDeviceName", ctypes.c_byte * 22),
        ("irdaDeviceHints1", ctypes.c_ubyte),
        ("irdaDeviceHints2", ctypes.c_ubyte),
        ("irdaCharSet", ctypes.c_ubyte),
    ]

class WINDOWS_DEVICELIST(ctypes.Structure):
    _fields_ = [
        ("numDevice", wintypes.DWORD),
        ("Device", WINDOWS_IRDA_DEVICE_INFO * 1),
    ]
#[repr(C)]
pub struct WINDOWS_IRDA_DEVICE_INFO {
    pub irdaDeviceID: [u8; 4],
    pub irdaDeviceName: [i8; 22],
    pub irdaDeviceHints1: u8,
    pub irdaDeviceHints2: u8,
    pub irdaCharSet: u8,
}

#[repr(C)]
pub struct WINDOWS_DEVICELIST {
    pub numDevice: u32,
    pub Device: [WINDOWS_IRDA_DEVICE_INFO; 1],
}
import "golang.org/x/sys/windows"

type WINDOWS_IRDA_DEVICE_INFO struct {
	irdaDeviceID [4]byte
	irdaDeviceName [22]int8
	irdaDeviceHints1 byte
	irdaDeviceHints2 byte
	irdaCharSet byte
}

type WINDOWS_DEVICELIST struct {
	numDevice uint32
	Device [1]WINDOWS_IRDA_DEVICE_INFO
}
type
  WINDOWS_IRDA_DEVICE_INFO = record
    irdaDeviceID: array[0..3] of Byte;
    irdaDeviceName: array[0..21] of Shortint;
    irdaDeviceHints1: Byte;
    irdaDeviceHints2: Byte;
    irdaCharSet: Byte;
  end;

  WINDOWS_DEVICELIST = record
    numDevice: DWORD;
    Device: array[0..0] of WINDOWS_IRDA_DEVICE_INFO;
  end;
const WINDOWS_IRDA_DEVICE_INFO = extern struct {
    irdaDeviceID: [4]u8,
    irdaDeviceName: [22]i8,
    irdaDeviceHints1: u8,
    irdaDeviceHints2: u8,
    irdaCharSet: u8,
};

const WINDOWS_DEVICELIST = extern struct {
    numDevice: u32,
    Device: [1]WINDOWS_IRDA_DEVICE_INFO,
};
type
  WINDOWS_IRDA_DEVICE_INFO {.bycopy.} = object
    irdaDeviceID: array[4, uint8]
    irdaDeviceName: array[22, int8]
    irdaDeviceHints1: uint8
    irdaDeviceHints2: uint8
    irdaCharSet: uint8

  WINDOWS_DEVICELIST {.bycopy.} = object
    numDevice: uint32
    Device: array[1, WINDOWS_IRDA_DEVICE_INFO]
struct WINDOWS_IRDA_DEVICE_INFO
{
    ubyte[4] irdaDeviceID;
    byte[22] irdaDeviceName;
    ubyte irdaDeviceHints1;
    ubyte irdaDeviceHints2;
    ubyte irdaCharSet;
}

struct WINDOWS_DEVICELIST
{
    uint numDevice;
    WINDOWS_IRDA_DEVICE_INFO[1] Device;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WINDOWS_DEVICELIST サイズ: 36 バイト(x64)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; numDevice : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Device : WINDOWS_IRDA_DEVICE_INFO (+4, 29byte)  varptr(st)+4 を基点に操作(29byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global WINDOWS_IRDA_DEVICE_INFO
    #field byte irdaDeviceID 4
    #field byte irdaDeviceName 22
    #field byte irdaDeviceHints1
    #field byte irdaDeviceHints2
    #field byte irdaCharSet
#endstruct

#defstruct global WINDOWS_DEVICELIST
    #field int numDevice
    #field WINDOWS_IRDA_DEVICE_INFO Device 1
#endstruct

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