Win32 API 日本語リファレンス
ホームDevices.Fax › STI_DIAG

STI_DIAG

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

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

フィールド

フィールドサイズx64x86説明
dwSizeDWORD4+0+0この構造体のサイズをバイト単位で示すDWORD。
dwBasicDiagCodeDWORD4+4+4基本診断結果コードを示すDWORD。
dwVendorDiagCodeDWORD4+8+8ベンダ固有の診断結果コードを示すDWORD。
dwStatusMaskDWORD4+12+12診断時の状態を示すビットマスクのDWORD。
sErrorInfo_ERROR_INFOW524+16+16詳細なエラー情報を保持する_ERROR_INFOW構造体。

各言語での定義

#include <windows.h>

// _ERROR_INFOW  (x64 524 / x86 524 バイト)
typedef struct _ERROR_INFOW {
    DWORD dwSize;
    DWORD dwGenericError;
    DWORD dwVendorError;
    WCHAR szExtendedErrorText[255];
} _ERROR_INFOW;

// STI_DIAG  (x64 540 / x86 540 バイト)
typedef struct STI_DIAG {
    DWORD dwSize;
    DWORD dwBasicDiagCode;
    DWORD dwVendorDiagCode;
    DWORD dwStatusMask;
    _ERROR_INFOW sErrorInfo;
} STI_DIAG;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct _ERROR_INFOW
{
    public uint dwSize;
    public uint dwGenericError;
    public uint dwVendorError;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 255)] public string szExtendedErrorText;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STI_DIAG
{
    public uint dwSize;
    public uint dwBasicDiagCode;
    public uint dwVendorDiagCode;
    public uint dwStatusMask;
    public _ERROR_INFOW sErrorInfo;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure _ERROR_INFOW
    Public dwSize As UInteger
    Public dwGenericError As UInteger
    Public dwVendorError As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=255)> Public szExtendedErrorText As String
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STI_DIAG
    Public dwSize As UInteger
    Public dwBasicDiagCode As UInteger
    Public dwVendorDiagCode As UInteger
    Public dwStatusMask As UInteger
    Public sErrorInfo As _ERROR_INFOW
End Structure
import ctypes
from ctypes import wintypes

class _ERROR_INFOW(ctypes.Structure):
    _fields_ = [
        ("dwSize", wintypes.DWORD),
        ("dwGenericError", wintypes.DWORD),
        ("dwVendorError", wintypes.DWORD),
        ("szExtendedErrorText", ctypes.c_wchar * 255),
    ]

class STI_DIAG(ctypes.Structure):
    _fields_ = [
        ("dwSize", wintypes.DWORD),
        ("dwBasicDiagCode", wintypes.DWORD),
        ("dwVendorDiagCode", wintypes.DWORD),
        ("dwStatusMask", wintypes.DWORD),
        ("sErrorInfo", _ERROR_INFOW),
    ]
#[repr(C)]
pub struct _ERROR_INFOW {
    pub dwSize: u32,
    pub dwGenericError: u32,
    pub dwVendorError: u32,
    pub szExtendedErrorText: [u16; 255],
}

#[repr(C)]
pub struct STI_DIAG {
    pub dwSize: u32,
    pub dwBasicDiagCode: u32,
    pub dwVendorDiagCode: u32,
    pub dwStatusMask: u32,
    pub sErrorInfo: _ERROR_INFOW,
}
import "golang.org/x/sys/windows"

type _ERROR_INFOW struct {
	dwSize uint32
	dwGenericError uint32
	dwVendorError uint32
	szExtendedErrorText [255]uint16
}

type STI_DIAG struct {
	dwSize uint32
	dwBasicDiagCode uint32
	dwVendorDiagCode uint32
	dwStatusMask uint32
	sErrorInfo _ERROR_INFOW
}
type
  _ERROR_INFOW = record
    dwSize: DWORD;
    dwGenericError: DWORD;
    dwVendorError: DWORD;
    szExtendedErrorText: array[0..254] of WideChar;
  end;

  STI_DIAG = record
    dwSize: DWORD;
    dwBasicDiagCode: DWORD;
    dwVendorDiagCode: DWORD;
    dwStatusMask: DWORD;
    sErrorInfo: _ERROR_INFOW;
  end;
const _ERROR_INFOW = extern struct {
    dwSize: u32,
    dwGenericError: u32,
    dwVendorError: u32,
    szExtendedErrorText: [255]u16,
};

const STI_DIAG = extern struct {
    dwSize: u32,
    dwBasicDiagCode: u32,
    dwVendorDiagCode: u32,
    dwStatusMask: u32,
    sErrorInfo: _ERROR_INFOW,
};
type
  _ERROR_INFOW {.bycopy.} = object
    dwSize: uint32
    dwGenericError: uint32
    dwVendorError: uint32
    szExtendedErrorText: array[255, uint16]

  STI_DIAG {.bycopy.} = object
    dwSize: uint32
    dwBasicDiagCode: uint32
    dwVendorDiagCode: uint32
    dwStatusMask: uint32
    sErrorInfo: _ERROR_INFOW
struct _ERROR_INFOW
{
    uint dwSize;
    uint dwGenericError;
    uint dwVendorError;
    wchar[255] szExtendedErrorText;
}

struct STI_DIAG
{
    uint dwSize;
    uint dwBasicDiagCode;
    uint dwVendorDiagCode;
    uint dwStatusMask;
    _ERROR_INFOW sErrorInfo;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STI_DIAG サイズ: 540 バイト(x64)
dim st, 135    ; 4byte整数×135(構造体サイズ 540 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwBasicDiagCode : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwVendorDiagCode : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dwStatusMask : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; sErrorInfo : _ERROR_INFOW (+16, 524byte)  varptr(st)+16 を基点に操作(524byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global _ERROR_INFOW
    #field int dwSize
    #field int dwGenericError
    #field int dwVendorError
    #field wchar szExtendedErrorText 255
#endstruct

#defstruct global STI_DIAG
    #field int dwSize
    #field int dwBasicDiagCode
    #field int dwVendorDiagCode
    #field int dwStatusMask
    #field _ERROR_INFOW sErrorInfo
#endstruct

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