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

WebSocketCompleteAction

関数
WebSocketのアクションを完了済みとして通知する。
DLLwebsocket.dll呼出規約winapi対応OSwindows8.0

シグネチャ

// websocket.dll
#include <windows.h>

void WebSocketCompleteAction(
    WEB_SOCKET_HANDLE hWebSocket,
    void* pvActionContext,
    DWORD ulBytesTransferred
);

パラメーター

名前方向説明
hWebSocketWEB_SOCKET_HANDLEin対象のWebSocketセッションハンドル。
pvActionContextvoid*inGetActionで得たアクションコンテキスト。完了対象を識別する。
ulBytesTransferredDWORDin当該アクションで実際に転送されたバイト数。

戻り値の型: void

各言語での呼び出し定義

// websocket.dll
#include <windows.h>

void WebSocketCompleteAction(
    WEB_SOCKET_HANDLE hWebSocket,
    void* pvActionContext,
    DWORD ulBytesTransferred
);
[DllImport("websocket.dll", ExactSpelling = true)]
static extern void WebSocketCompleteAction(
    IntPtr hWebSocket,   // WEB_SOCKET_HANDLE
    IntPtr pvActionContext,   // void*
    uint ulBytesTransferred   // DWORD
);
<DllImport("websocket.dll", ExactSpelling:=True)>
Public Shared Sub WebSocketCompleteAction(
    hWebSocket As IntPtr,   ' WEB_SOCKET_HANDLE
    pvActionContext As IntPtr,   ' void*
    ulBytesTransferred As UInteger   ' DWORD
)
End Sub
' hWebSocket : WEB_SOCKET_HANDLE
' pvActionContext : void*
' ulBytesTransferred : DWORD
Declare PtrSafe Sub WebSocketCompleteAction Lib "websocket" ( _
    ByVal hWebSocket As LongPtr, _
    ByVal pvActionContext As LongPtr, _
    ByVal ulBytesTransferred As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WebSocketCompleteAction = ctypes.windll.websocket.WebSocketCompleteAction
WebSocketCompleteAction.restype = None
WebSocketCompleteAction.argtypes = [
    wintypes.HANDLE,  # hWebSocket : WEB_SOCKET_HANDLE
    ctypes.POINTER(None),  # pvActionContext : void*
    wintypes.DWORD,  # ulBytesTransferred : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('websocket.dll')
WebSocketCompleteAction = Fiddle::Function.new(
  lib['WebSocketCompleteAction'],
  [
    Fiddle::TYPE_VOIDP,  # hWebSocket : WEB_SOCKET_HANDLE
    Fiddle::TYPE_VOIDP,  # pvActionContext : void*
    -Fiddle::TYPE_INT,  # ulBytesTransferred : DWORD
  ],
  Fiddle::TYPE_VOID)
#[link(name = "websocket")]
extern "system" {
    fn WebSocketCompleteAction(
        hWebSocket: *mut core::ffi::c_void,  // WEB_SOCKET_HANDLE
        pvActionContext: *mut (),  // void*
        ulBytesTransferred: u32  // DWORD
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("websocket.dll")]
public static extern void WebSocketCompleteAction(IntPtr hWebSocket, IntPtr pvActionContext, uint ulBytesTransferred);
"@
$api = Add-Type -MemberDefinition $sig -Name 'websocket_WebSocketCompleteAction' -Namespace Win32 -PassThru
# $api::WebSocketCompleteAction(hWebSocket, pvActionContext, ulBytesTransferred)
#uselib "websocket.dll"
#func global WebSocketCompleteAction "WebSocketCompleteAction" sptr, sptr, sptr
; WebSocketCompleteAction hWebSocket, pvActionContext, ulBytesTransferred
; hWebSocket : WEB_SOCKET_HANDLE -> "sptr"
; pvActionContext : void* -> "sptr"
; ulBytesTransferred : DWORD -> "sptr"
#uselib "websocket.dll"
#func global WebSocketCompleteAction "WebSocketCompleteAction" sptr, sptr, int
; WebSocketCompleteAction hWebSocket, pvActionContext, ulBytesTransferred
; hWebSocket : WEB_SOCKET_HANDLE -> "sptr"
; pvActionContext : void* -> "sptr"
; ulBytesTransferred : DWORD -> "int"
; void WebSocketCompleteAction(WEB_SOCKET_HANDLE hWebSocket, void* pvActionContext, DWORD ulBytesTransferred)
#uselib "websocket.dll"
#func global WebSocketCompleteAction "WebSocketCompleteAction" intptr, intptr, int
; WebSocketCompleteAction hWebSocket, pvActionContext, ulBytesTransferred
; hWebSocket : WEB_SOCKET_HANDLE -> "intptr"
; pvActionContext : void* -> "intptr"
; ulBytesTransferred : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	websocket = windows.NewLazySystemDLL("websocket.dll")
	procWebSocketCompleteAction = websocket.NewProc("WebSocketCompleteAction")
)

// hWebSocket (WEB_SOCKET_HANDLE), pvActionContext (void*), ulBytesTransferred (DWORD)
r1, _, err := procWebSocketCompleteAction.Call(
	uintptr(hWebSocket),
	uintptr(pvActionContext),
	uintptr(ulBytesTransferred),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure WebSocketCompleteAction(
  hWebSocket: THandle;   // WEB_SOCKET_HANDLE
  pvActionContext: Pointer;   // void*
  ulBytesTransferred: DWORD   // DWORD
); stdcall;
  external 'websocket.dll' name 'WebSocketCompleteAction';
result := DllCall("websocket\WebSocketCompleteAction"
    , "Ptr", hWebSocket   ; WEB_SOCKET_HANDLE
    , "Ptr", pvActionContext   ; void*
    , "UInt", ulBytesTransferred   ; DWORD
    , "Int")   ; return: void
●WebSocketCompleteAction(hWebSocket, pvActionContext, ulBytesTransferred) = DLL("websocket.dll", "int WebSocketCompleteAction(void*, void*, dword)")
# 呼び出し: WebSocketCompleteAction(hWebSocket, pvActionContext, ulBytesTransferred)
# hWebSocket : WEB_SOCKET_HANDLE -> "void*"
# pvActionContext : void* -> "void*"
# ulBytesTransferred : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "websocket" fn WebSocketCompleteAction(
    hWebSocket: ?*anyopaque, // WEB_SOCKET_HANDLE
    pvActionContext: ?*anyopaque, // void*
    ulBytesTransferred: u32 // DWORD
) callconv(std.os.windows.WINAPI) void;
proc WebSocketCompleteAction(
    hWebSocket: pointer,  # WEB_SOCKET_HANDLE
    pvActionContext: pointer,  # void*
    ulBytesTransferred: uint32  # DWORD
) {.importc: "WebSocketCompleteAction", stdcall, dynlib: "websocket.dll".}
pragma(lib, "websocket");
extern(Windows)
void WebSocketCompleteAction(
    void* hWebSocket,   // WEB_SOCKET_HANDLE
    void* pvActionContext,   // void*
    uint ulBytesTransferred   // DWORD
);
ccall((:WebSocketCompleteAction, "websocket.dll"), stdcall, Cvoid,
      (Ptr{Cvoid}, Ptr{Cvoid}, UInt32),
      hWebSocket, pvActionContext, ulBytesTransferred)
# hWebSocket : WEB_SOCKET_HANDLE -> Ptr{Cvoid}
# pvActionContext : void* -> Ptr{Cvoid}
# ulBytesTransferred : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void WebSocketCompleteAction(
    void* hWebSocket,
    void* pvActionContext,
    uint32_t ulBytesTransferred);
]]
local websocket = ffi.load("websocket")
-- websocket.WebSocketCompleteAction(hWebSocket, pvActionContext, ulBytesTransferred)
-- hWebSocket : WEB_SOCKET_HANDLE
-- pvActionContext : void*
-- ulBytesTransferred : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('websocket.dll');
const WebSocketCompleteAction = lib.func('__stdcall', 'WebSocketCompleteAction', 'void', ['void *', 'void *', 'uint32_t']);
// WebSocketCompleteAction(hWebSocket, pvActionContext, ulBytesTransferred)
// hWebSocket : WEB_SOCKET_HANDLE -> 'void *'
// pvActionContext : void* -> 'void *'
// ulBytesTransferred : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("websocket.dll", {
  WebSocketCompleteAction: { parameters: ["pointer", "pointer", "u32"], result: "void" },
});
// lib.symbols.WebSocketCompleteAction(hWebSocket, pvActionContext, ulBytesTransferred)
// hWebSocket : WEB_SOCKET_HANDLE -> "pointer"
// pvActionContext : void* -> "pointer"
// ulBytesTransferred : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void WebSocketCompleteAction(
    void* hWebSocket,
    void* pvActionContext,
    uint32_t ulBytesTransferred);
C, "websocket.dll");
// $ffi->WebSocketCompleteAction(hWebSocket, pvActionContext, ulBytesTransferred);
// hWebSocket : WEB_SOCKET_HANDLE
// pvActionContext : void*
// ulBytesTransferred : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Websocket extends StdCallLibrary {
    Websocket INSTANCE = Native.load("websocket", Websocket.class);
    void WebSocketCompleteAction(
        Pointer hWebSocket,   // WEB_SOCKET_HANDLE
        Pointer pvActionContext,   // void*
        int ulBytesTransferred   // DWORD
    );
}
@[Link("websocket")]
lib Libwebsocket
  fun WebSocketCompleteAction = WebSocketCompleteAction(
    hWebSocket : Void*,   # WEB_SOCKET_HANDLE
    pvActionContext : Void*,   # void*
    ulBytesTransferred : UInt32   # DWORD
  ) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WebSocketCompleteActionNative = Void Function(Pointer<Void>, Pointer<Void>, Uint32);
typedef WebSocketCompleteActionDart = void Function(Pointer<Void>, Pointer<Void>, int);
final WebSocketCompleteAction = DynamicLibrary.open('websocket.dll')
    .lookupFunction<WebSocketCompleteActionNative, WebSocketCompleteActionDart>('WebSocketCompleteAction');
// hWebSocket : WEB_SOCKET_HANDLE -> Pointer<Void>
// pvActionContext : void* -> Pointer<Void>
// ulBytesTransferred : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure WebSocketCompleteAction(
  hWebSocket: THandle;   // WEB_SOCKET_HANDLE
  pvActionContext: Pointer;   // void*
  ulBytesTransferred: DWORD   // DWORD
); stdcall;
  external 'websocket.dll' name 'WebSocketCompleteAction';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WebSocketCompleteAction"
  c_WebSocketCompleteAction :: Ptr () -> Ptr () -> Word32 -> IO ()
-- hWebSocket : WEB_SOCKET_HANDLE -> Ptr ()
-- pvActionContext : void* -> Ptr ()
-- ulBytesTransferred : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let websocketcompleteaction =
  foreign "WebSocketCompleteAction"
    ((ptr void) @-> (ptr void) @-> uint32_t @-> returning void)
(* hWebSocket : WEB_SOCKET_HANDLE -> (ptr void) *)
(* pvActionContext : void* -> (ptr void) *)
(* ulBytesTransferred : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library websocket (t "websocket.dll"))
(cffi:use-foreign-library websocket)

(cffi:defcfun ("WebSocketCompleteAction" web-socket-complete-action :convention :stdcall) :void
  (h-web-socket :pointer)   ; WEB_SOCKET_HANDLE
  (pv-action-context :pointer)   ; void*
  (ul-bytes-transferred :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WebSocketCompleteAction = Win32::API::More->new('websocket',
    'void WebSocketCompleteAction(HANDLE hWebSocket, LPVOID pvActionContext, DWORD ulBytesTransferred)');
# my $ret = $WebSocketCompleteAction->Call($hWebSocket, $pvActionContext, $ulBytesTransferred);
# hWebSocket : WEB_SOCKET_HANDLE -> HANDLE
# pvActionContext : void* -> LPVOID
# ulBytesTransferred : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。