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

WinHttpWebSocketShutdown

関数
WebSocket接続の送信方向を終了する。
DLLWINHTTP.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD WinHttpWebSocketShutdown(
    void* hWebSocket,
    WORD usStatus,
    void* pvReason,   // optional
    DWORD dwReasonLength
);

パラメーター

名前方向
hWebSocketvoid*in
usStatusWORDin
pvReasonvoid*inoptional
dwReasonLengthDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD WinHttpWebSocketShutdown(
    void* hWebSocket,
    WORD usStatus,
    void* pvReason,   // optional
    DWORD dwReasonLength
);
[DllImport("WINHTTP.dll", ExactSpelling = true)]
static extern uint WinHttpWebSocketShutdown(
    IntPtr hWebSocket,   // void*
    ushort usStatus,   // WORD
    IntPtr pvReason,   // void* optional
    uint dwReasonLength   // DWORD
);
<DllImport("WINHTTP.dll", ExactSpelling:=True)>
Public Shared Function WinHttpWebSocketShutdown(
    hWebSocket As IntPtr,   ' void*
    usStatus As UShort,   ' WORD
    pvReason As IntPtr,   ' void* optional
    dwReasonLength As UInteger   ' DWORD
) As UInteger
End Function
' hWebSocket : void*
' usStatus : WORD
' pvReason : void* optional
' dwReasonLength : DWORD
Declare PtrSafe Function WinHttpWebSocketShutdown Lib "winhttp" ( _
    ByVal hWebSocket As LongPtr, _
    ByVal usStatus As Integer, _
    ByVal pvReason As LongPtr, _
    ByVal dwReasonLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinHttpWebSocketShutdown = ctypes.windll.winhttp.WinHttpWebSocketShutdown
WinHttpWebSocketShutdown.restype = wintypes.DWORD
WinHttpWebSocketShutdown.argtypes = [
    ctypes.POINTER(None),  # hWebSocket : void*
    ctypes.c_ushort,  # usStatus : WORD
    ctypes.POINTER(None),  # pvReason : void* optional
    wintypes.DWORD,  # dwReasonLength : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINHTTP.dll')
WinHttpWebSocketShutdown = Fiddle::Function.new(
  lib['WinHttpWebSocketShutdown'],
  [
    Fiddle::TYPE_VOIDP,  # hWebSocket : void*
    -Fiddle::TYPE_SHORT,  # usStatus : WORD
    Fiddle::TYPE_VOIDP,  # pvReason : void* optional
    -Fiddle::TYPE_INT,  # dwReasonLength : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "winhttp")]
extern "system" {
    fn WinHttpWebSocketShutdown(
        hWebSocket: *mut (),  // void*
        usStatus: u16,  // WORD
        pvReason: *mut (),  // void* optional
        dwReasonLength: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WINHTTP.dll")]
public static extern uint WinHttpWebSocketShutdown(IntPtr hWebSocket, ushort usStatus, IntPtr pvReason, uint dwReasonLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpWebSocketShutdown' -Namespace Win32 -PassThru
# $api::WinHttpWebSocketShutdown(hWebSocket, usStatus, pvReason, dwReasonLength)
#uselib "WINHTTP.dll"
#func global WinHttpWebSocketShutdown "WinHttpWebSocketShutdown" sptr, sptr, sptr, sptr
; WinHttpWebSocketShutdown hWebSocket, usStatus, pvReason, dwReasonLength   ; 戻り値は stat
; hWebSocket : void* -> "sptr"
; usStatus : WORD -> "sptr"
; pvReason : void* optional -> "sptr"
; dwReasonLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WINHTTP.dll"
#cfunc global WinHttpWebSocketShutdown "WinHttpWebSocketShutdown" sptr, int, sptr, int
; res = WinHttpWebSocketShutdown(hWebSocket, usStatus, pvReason, dwReasonLength)
; hWebSocket : void* -> "sptr"
; usStatus : WORD -> "int"
; pvReason : void* optional -> "sptr"
; dwReasonLength : DWORD -> "int"
; DWORD WinHttpWebSocketShutdown(void* hWebSocket, WORD usStatus, void* pvReason, DWORD dwReasonLength)
#uselib "WINHTTP.dll"
#cfunc global WinHttpWebSocketShutdown "WinHttpWebSocketShutdown" intptr, int, intptr, int
; res = WinHttpWebSocketShutdown(hWebSocket, usStatus, pvReason, dwReasonLength)
; hWebSocket : void* -> "intptr"
; usStatus : WORD -> "int"
; pvReason : void* optional -> "intptr"
; dwReasonLength : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhttp = windows.NewLazySystemDLL("WINHTTP.dll")
	procWinHttpWebSocketShutdown = winhttp.NewProc("WinHttpWebSocketShutdown")
)

// hWebSocket (void*), usStatus (WORD), pvReason (void* optional), dwReasonLength (DWORD)
r1, _, err := procWinHttpWebSocketShutdown.Call(
	uintptr(hWebSocket),
	uintptr(usStatus),
	uintptr(pvReason),
	uintptr(dwReasonLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WinHttpWebSocketShutdown(
  hWebSocket: Pointer;   // void*
  usStatus: Word;   // WORD
  pvReason: Pointer;   // void* optional
  dwReasonLength: DWORD   // DWORD
): DWORD; stdcall;
  external 'WINHTTP.dll' name 'WinHttpWebSocketShutdown';
result := DllCall("WINHTTP\WinHttpWebSocketShutdown"
    , "Ptr", hWebSocket   ; void*
    , "UShort", usStatus   ; WORD
    , "Ptr", pvReason   ; void* optional
    , "UInt", dwReasonLength   ; DWORD
    , "UInt")   ; return: DWORD
●WinHttpWebSocketShutdown(hWebSocket, usStatus, pvReason, dwReasonLength) = DLL("WINHTTP.dll", "dword WinHttpWebSocketShutdown(void*, int, void*, dword)")
# 呼び出し: WinHttpWebSocketShutdown(hWebSocket, usStatus, pvReason, dwReasonLength)
# hWebSocket : void* -> "void*"
# usStatus : WORD -> "int"
# pvReason : void* optional -> "void*"
# dwReasonLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。