ホーム › System.Com › DVTARGETDEVICE
DVTARGETDEVICE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| tdSize | DWORD | 4 | +0 | +0 | この構造体全体のバイトサイズ(可変長データを含む)。 |
| tdDriverNameOffset | WORD | 2 | +4 | +4 | ドライバ名文字列への構造体先頭からのオフセット。0でなし。 |
| tdDeviceNameOffset | WORD | 2 | +6 | +6 | デバイス名文字列へのオフセット。0でなし。 |
| tdPortNameOffset | WORD | 2 | +8 | +8 | ポート名文字列へのオフセット。0でなし。 |
| tdExtDevmodeOffset | WORD | 2 | +10 | +10 | DEVMODE構造体へのオフセット。0でなし。 |
| tdData | BYTE | 1 | +12 | +12 | 上記オフセットが参照する可変長データの先頭。 |
各言語での定義
#include <windows.h>
// DVTARGETDEVICE (x64 16 / x86 16 バイト)
typedef struct DVTARGETDEVICE {
DWORD tdSize;
WORD tdDriverNameOffset;
WORD tdDeviceNameOffset;
WORD tdPortNameOffset;
WORD tdExtDevmodeOffset;
BYTE tdData[1];
} DVTARGETDEVICE;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DVTARGETDEVICE
{
public uint tdSize;
public ushort tdDriverNameOffset;
public ushort tdDeviceNameOffset;
public ushort tdPortNameOffset;
public ushort tdExtDevmodeOffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] tdData;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DVTARGETDEVICE
Public tdSize As UInteger
Public tdDriverNameOffset As UShort
Public tdDeviceNameOffset As UShort
Public tdPortNameOffset As UShort
Public tdExtDevmodeOffset As UShort
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public tdData() As Byte
End Structureimport ctypes
from ctypes import wintypes
class DVTARGETDEVICE(ctypes.Structure):
_fields_ = [
("tdSize", wintypes.DWORD),
("tdDriverNameOffset", ctypes.c_ushort),
("tdDeviceNameOffset", ctypes.c_ushort),
("tdPortNameOffset", ctypes.c_ushort),
("tdExtDevmodeOffset", ctypes.c_ushort),
("tdData", ctypes.c_ubyte * 1),
]#[repr(C)]
pub struct DVTARGETDEVICE {
pub tdSize: u32,
pub tdDriverNameOffset: u16,
pub tdDeviceNameOffset: u16,
pub tdPortNameOffset: u16,
pub tdExtDevmodeOffset: u16,
pub tdData: [u8; 1],
}import "golang.org/x/sys/windows"
type DVTARGETDEVICE struct {
tdSize uint32
tdDriverNameOffset uint16
tdDeviceNameOffset uint16
tdPortNameOffset uint16
tdExtDevmodeOffset uint16
tdData [1]byte
}type
DVTARGETDEVICE = record
tdSize: DWORD;
tdDriverNameOffset: Word;
tdDeviceNameOffset: Word;
tdPortNameOffset: Word;
tdExtDevmodeOffset: Word;
tdData: array[0..0] of Byte;
end;const DVTARGETDEVICE = extern struct {
tdSize: u32,
tdDriverNameOffset: u16,
tdDeviceNameOffset: u16,
tdPortNameOffset: u16,
tdExtDevmodeOffset: u16,
tdData: [1]u8,
};type
DVTARGETDEVICE {.bycopy.} = object
tdSize: uint32
tdDriverNameOffset: uint16
tdDeviceNameOffset: uint16
tdPortNameOffset: uint16
tdExtDevmodeOffset: uint16
tdData: array[1, uint8]struct DVTARGETDEVICE
{
uint tdSize;
ushort tdDriverNameOffset;
ushort tdDeviceNameOffset;
ushort tdPortNameOffset;
ushort tdExtDevmodeOffset;
ubyte[1] tdData;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DVTARGETDEVICE サイズ: 16 バイト(x64)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; tdSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; tdDriverNameOffset : WORD (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; tdDeviceNameOffset : WORD (+6, 2byte) wpoke st,6,値 / 値 = wpeek(st,6)
; tdPortNameOffset : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; tdExtDevmodeOffset : WORD (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; tdData : BYTE (+12, 1byte) varptr(st)+12 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DVTARGETDEVICE
#field int tdSize
#field short tdDriverNameOffset
#field short tdDeviceNameOffset
#field short tdPortNameOffset
#field short tdExtDevmodeOffset
#field byte tdData 1
#endstruct
stdim st, DVTARGETDEVICE ; NSTRUCT 変数を確保
st->tdSize = 100
mes "tdSize=" + st->tdSize