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

WSPDATA

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

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

フィールド

フィールドサイズx64x86説明
wVersionWORD2+0+0Windows Sockets サービスプロバイダーが呼び出し元に使用させることを想定している、Windows Sockets SPI 仕様のバージョンです。
wHighVersionWORD2+2+2このサービスプロバイダーがサポートできる Windows Sockets SPI 仕様の最上位バージョンです (エンコード方法は上記と同じです)。通常は wVersion と同じ値になります。
szDescriptionWCHAR512+4+4Windows Sockets プロバイダーが自身の説明をコピーする、NULL で終わる Unicode 文字列です。このテキスト (最大 256 文字) には、制御文字と書式設定文字を除く任意の文字を含めることができます。SPI クライアントによる最も一般的な用途は、この文字列を (必要に応じて切り詰めて) ステータスメッセージに表示することです。

公式ドキュメント

WSPDATA 構造体は、サービスプロバイダーの情報を格納します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// WSPDATA  (x64 516 / x86 516 バイト)
typedef struct WSPDATA {
    WORD wVersion;
    WORD wHighVersion;
    WCHAR szDescription[256];
} WSPDATA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSPDATA
{
    public ushort wVersion;
    public ushort wHighVersion;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string szDescription;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WSPDATA
    Public wVersion As UShort
    Public wHighVersion As UShort
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public szDescription As String
End Structure
import ctypes
from ctypes import wintypes

class WSPDATA(ctypes.Structure):
    _fields_ = [
        ("wVersion", ctypes.c_ushort),
        ("wHighVersion", ctypes.c_ushort),
        ("szDescription", ctypes.c_wchar * 256),
    ]
#[repr(C)]
pub struct WSPDATA {
    pub wVersion: u16,
    pub wHighVersion: u16,
    pub szDescription: [u16; 256],
}
import "golang.org/x/sys/windows"

type WSPDATA struct {
	wVersion uint16
	wHighVersion uint16
	szDescription [256]uint16
}
type
  WSPDATA = record
    wVersion: Word;
    wHighVersion: Word;
    szDescription: array[0..255] of WideChar;
  end;
const WSPDATA = extern struct {
    wVersion: u16,
    wHighVersion: u16,
    szDescription: [256]u16,
};
type
  WSPDATA {.bycopy.} = object
    wVersion: uint16
    wHighVersion: uint16
    szDescription: array[256, uint16]
struct WSPDATA
{
    ushort wVersion;
    ushort wHighVersion;
    wchar[256] szDescription;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WSPDATA サイズ: 516 バイト(x64)
dim st, 129    ; 4byte整数×129(構造体サイズ 516 / 4 切り上げ)
; wVersion : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; wHighVersion : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; szDescription : WCHAR (+4, 512byte)  varptr(st)+4 を基点に操作(512byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WSPDATA
    #field short wVersion
    #field short wHighVersion
    #field wchar szDescription 256
#endstruct

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