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

WSASENDMSG

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

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

フィールド

フィールドサイズx64x86説明
lpMsgWSAMSG*8/4+0+0送信するメッセージ内容を記述するWSAMSG構造体へのポインタ。
dwFlagsDWORD4+8+4送信動作を制御するフラグのビットマスク。
lpNumberOfBytesSentDWORD*8/4+16+8送信されたバイト数を受け取る変数へのポインタ。
lpOverlappedOVERLAPPED*8/4+24+12重複I/Oに用いるOVERLAPPED構造体へのポインタ。同期時はNULL。
lpCompletionRoutineLPWSAOVERLAPPED_COMPLETION_ROUTINE8/4+32+16I/O完了時に呼ばれる完了ルーチンへのポインタ。

各言語での定義

#include <windows.h>

// WSASENDMSG  (x64 40 / x86 20 バイト)
typedef struct WSASENDMSG {
    WSAMSG* lpMsg;
    DWORD dwFlags;
    DWORD* lpNumberOfBytesSent;
    OVERLAPPED* lpOverlapped;
    LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine;
} WSASENDMSG;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSASENDMSG
{
    public IntPtr lpMsg;
    public uint dwFlags;
    public IntPtr lpNumberOfBytesSent;
    public IntPtr lpOverlapped;
    public IntPtr lpCompletionRoutine;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WSASENDMSG
    Public lpMsg As IntPtr
    Public dwFlags As UInteger
    Public lpNumberOfBytesSent As IntPtr
    Public lpOverlapped As IntPtr
    Public lpCompletionRoutine As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class WSASENDMSG(ctypes.Structure):
    _fields_ = [
        ("lpMsg", ctypes.c_void_p),
        ("dwFlags", wintypes.DWORD),
        ("lpNumberOfBytesSent", ctypes.c_void_p),
        ("lpOverlapped", ctypes.c_void_p),
        ("lpCompletionRoutine", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct WSASENDMSG {
    pub lpMsg: *mut core::ffi::c_void,
    pub dwFlags: u32,
    pub lpNumberOfBytesSent: *mut core::ffi::c_void,
    pub lpOverlapped: *mut core::ffi::c_void,
    pub lpCompletionRoutine: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type WSASENDMSG struct {
	lpMsg uintptr
	dwFlags uint32
	lpNumberOfBytesSent uintptr
	lpOverlapped uintptr
	lpCompletionRoutine uintptr
}
type
  WSASENDMSG = record
    lpMsg: Pointer;
    dwFlags: DWORD;
    lpNumberOfBytesSent: Pointer;
    lpOverlapped: Pointer;
    lpCompletionRoutine: Pointer;
  end;
const WSASENDMSG = extern struct {
    lpMsg: ?*anyopaque,
    dwFlags: u32,
    lpNumberOfBytesSent: ?*anyopaque,
    lpOverlapped: ?*anyopaque,
    lpCompletionRoutine: ?*anyopaque,
};
type
  WSASENDMSG {.bycopy.} = object
    lpMsg: pointer
    dwFlags: uint32
    lpNumberOfBytesSent: pointer
    lpOverlapped: pointer
    lpCompletionRoutine: pointer
struct WSASENDMSG
{
    void* lpMsg;
    uint dwFlags;
    void* lpNumberOfBytesSent;
    void* lpOverlapped;
    void* lpCompletionRoutine;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WSASENDMSG サイズ: 20 バイト(x86)
dim st, 5    ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; lpMsg : WSAMSG* (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; dwFlags : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; lpNumberOfBytesSent : DWORD* (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; lpOverlapped : OVERLAPPED* (+12, 4byte)  varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; lpCompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WSASENDMSG サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; lpMsg : WSAMSG* (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; dwFlags : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; lpNumberOfBytesSent : DWORD* (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; lpOverlapped : OVERLAPPED* (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; lpCompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WSASENDMSG
    #field intptr lpMsg
    #field int dwFlags
    #field intptr lpNumberOfBytesSent
    #field intptr lpOverlapped
    #field intptr lpCompletionRoutine
#endstruct

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