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

WinHttpWebSocketClose

関数
WebSocket接続を閉じる。
DLLWINHTTP.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

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

パラメーター

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

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD WinHttpWebSocketClose(
    void* hWebSocket,
    WORD usStatus,
    void* pvReason,   // optional
    DWORD dwReasonLength
);
[DllImport("WINHTTP.dll", ExactSpelling = true)]
static extern uint WinHttpWebSocketClose(
    IntPtr hWebSocket,   // void*
    ushort usStatus,   // WORD
    IntPtr pvReason,   // void* optional
    uint dwReasonLength   // DWORD
);
<DllImport("WINHTTP.dll", ExactSpelling:=True)>
Public Shared Function WinHttpWebSocketClose(
    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 WinHttpWebSocketClose 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

WinHttpWebSocketClose = ctypes.windll.winhttp.WinHttpWebSocketClose
WinHttpWebSocketClose.restype = wintypes.DWORD
WinHttpWebSocketClose.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')
WinHttpWebSocketClose = Fiddle::Function.new(
  lib['WinHttpWebSocketClose'],
  [
    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 WinHttpWebSocketClose(
        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 WinHttpWebSocketClose(IntPtr hWebSocket, ushort usStatus, IntPtr pvReason, uint dwReasonLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpWebSocketClose' -Namespace Win32 -PassThru
# $api::WinHttpWebSocketClose(hWebSocket, usStatus, pvReason, dwReasonLength)
#uselib "WINHTTP.dll"
#func global WinHttpWebSocketClose "WinHttpWebSocketClose" sptr, sptr, sptr, sptr
; WinHttpWebSocketClose 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 WinHttpWebSocketClose "WinHttpWebSocketClose" sptr, int, sptr, int
; res = WinHttpWebSocketClose(hWebSocket, usStatus, pvReason, dwReasonLength)
; hWebSocket : void* -> "sptr"
; usStatus : WORD -> "int"
; pvReason : void* optional -> "sptr"
; dwReasonLength : DWORD -> "int"
; DWORD WinHttpWebSocketClose(void* hWebSocket, WORD usStatus, void* pvReason, DWORD dwReasonLength)
#uselib "WINHTTP.dll"
#cfunc global WinHttpWebSocketClose "WinHttpWebSocketClose" intptr, int, intptr, int
; res = WinHttpWebSocketClose(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")
	procWinHttpWebSocketClose = winhttp.NewProc("WinHttpWebSocketClose")
)

// hWebSocket (void*), usStatus (WORD), pvReason (void* optional), dwReasonLength (DWORD)
r1, _, err := procWinHttpWebSocketClose.Call(
	uintptr(hWebSocket),
	uintptr(usStatus),
	uintptr(pvReason),
	uintptr(dwReasonLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WinHttpWebSocketClose(
  hWebSocket: Pointer;   // void*
  usStatus: Word;   // WORD
  pvReason: Pointer;   // void* optional
  dwReasonLength: DWORD   // DWORD
): DWORD; stdcall;
  external 'WINHTTP.dll' name 'WinHttpWebSocketClose';
result := DllCall("WINHTTP\WinHttpWebSocketClose"
    , "Ptr", hWebSocket   ; void*
    , "UShort", usStatus   ; WORD
    , "Ptr", pvReason   ; void* optional
    , "UInt", dwReasonLength   ; DWORD
    , "UInt")   ; return: DWORD
●WinHttpWebSocketClose(hWebSocket, usStatus, pvReason, dwReasonLength) = DLL("WINHTTP.dll", "dword WinHttpWebSocketClose(void*, int, void*, dword)")
# 呼び出し: WinHttpWebSocketClose(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)。