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

HttpWebSocketCompleteUpgrade

関数
HTTPからWebSocketへのアップグレードを完了する。
DLLWININET.dll呼出規約winapi

シグネチャ

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

void* HttpWebSocketCompleteUpgrade(
    void* hRequest,
    UINT_PTR dwContext
);

パラメーター

名前方向説明
hRequestvoid*inWebSocketへアップグレードするHTTPリクエストハンドル。
dwContextUINT_PTRinコールバックに渡されるアプリケーション定義のコンテキスト値(UINT_PTR)。

戻り値の型: void*

各言語での呼び出し定義

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

void* HttpWebSocketCompleteUpgrade(
    void* hRequest,
    UINT_PTR dwContext
);
[DllImport("WININET.dll", ExactSpelling = true)]
static extern IntPtr HttpWebSocketCompleteUpgrade(
    IntPtr hRequest,   // void*
    UIntPtr dwContext   // UINT_PTR
);
<DllImport("WININET.dll", ExactSpelling:=True)>
Public Shared Function HttpWebSocketCompleteUpgrade(
    hRequest As IntPtr,   ' void*
    dwContext As UIntPtr   ' UINT_PTR
) As IntPtr
End Function
' hRequest : void*
' dwContext : UINT_PTR
Declare PtrSafe Function HttpWebSocketCompleteUpgrade Lib "wininet" ( _
    ByVal hRequest As LongPtr, _
    ByVal dwContext As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HttpWebSocketCompleteUpgrade = ctypes.windll.wininet.HttpWebSocketCompleteUpgrade
HttpWebSocketCompleteUpgrade.restype = ctypes.c_void_p
HttpWebSocketCompleteUpgrade.argtypes = [
    ctypes.POINTER(None),  # hRequest : void*
    ctypes.c_size_t,  # dwContext : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
HttpWebSocketCompleteUpgrade = Fiddle::Function.new(
  lib['HttpWebSocketCompleteUpgrade'],
  [
    Fiddle::TYPE_VOIDP,  # hRequest : void*
    Fiddle::TYPE_UINTPTR_T,  # dwContext : UINT_PTR
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "wininet")]
extern "system" {
    fn HttpWebSocketCompleteUpgrade(
        hRequest: *mut (),  // void*
        dwContext: usize  // UINT_PTR
    ) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WININET.dll")]
public static extern IntPtr HttpWebSocketCompleteUpgrade(IntPtr hRequest, UIntPtr dwContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_HttpWebSocketCompleteUpgrade' -Namespace Win32 -PassThru
# $api::HttpWebSocketCompleteUpgrade(hRequest, dwContext)
#uselib "WININET.dll"
#func global HttpWebSocketCompleteUpgrade "HttpWebSocketCompleteUpgrade" sptr, sptr
; HttpWebSocketCompleteUpgrade hRequest, dwContext   ; 戻り値は stat
; hRequest : void* -> "sptr"
; dwContext : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WININET.dll"
#cfunc global HttpWebSocketCompleteUpgrade "HttpWebSocketCompleteUpgrade" sptr, sptr
; res = HttpWebSocketCompleteUpgrade(hRequest, dwContext)
; hRequest : void* -> "sptr"
; dwContext : UINT_PTR -> "sptr"
; void* HttpWebSocketCompleteUpgrade(void* hRequest, UINT_PTR dwContext)
#uselib "WININET.dll"
#cfunc global HttpWebSocketCompleteUpgrade "HttpWebSocketCompleteUpgrade" intptr, intptr
; res = HttpWebSocketCompleteUpgrade(hRequest, dwContext)
; hRequest : void* -> "intptr"
; dwContext : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procHttpWebSocketCompleteUpgrade = wininet.NewProc("HttpWebSocketCompleteUpgrade")
)

// hRequest (void*), dwContext (UINT_PTR)
r1, _, err := procHttpWebSocketCompleteUpgrade.Call(
	uintptr(hRequest),
	uintptr(dwContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void*
function HttpWebSocketCompleteUpgrade(
  hRequest: Pointer;   // void*
  dwContext: NativeUInt   // UINT_PTR
): Pointer; stdcall;
  external 'WININET.dll' name 'HttpWebSocketCompleteUpgrade';
result := DllCall("WININET\HttpWebSocketCompleteUpgrade"
    , "Ptr", hRequest   ; void*
    , "UPtr", dwContext   ; UINT_PTR
    , "Ptr")   ; return: void*
●HttpWebSocketCompleteUpgrade(hRequest, dwContext) = DLL("WININET.dll", "void* HttpWebSocketCompleteUpgrade(void*, int)")
# 呼び出し: HttpWebSocketCompleteUpgrade(hRequest, dwContext)
# hRequest : void* -> "void*"
# dwContext : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wininet" fn HttpWebSocketCompleteUpgrade(
    hRequest: ?*anyopaque, // void*
    dwContext: usize // UINT_PTR
) callconv(std.os.windows.WINAPI) ?*anyopaque;
proc HttpWebSocketCompleteUpgrade(
    hRequest: pointer,  # void*
    dwContext: uint  # UINT_PTR
): pointer {.importc: "HttpWebSocketCompleteUpgrade", stdcall, dynlib: "WININET.dll".}
pragma(lib, "wininet");
extern(Windows)
void* HttpWebSocketCompleteUpgrade(
    void* hRequest,   // void*
    size_t dwContext   // UINT_PTR
);
ccall((:HttpWebSocketCompleteUpgrade, "WININET.dll"), stdcall, Ptr{Cvoid},
      (Ptr{Cvoid}, Csize_t),
      hRequest, dwContext)
# hRequest : void* -> Ptr{Cvoid}
# dwContext : UINT_PTR -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void* HttpWebSocketCompleteUpgrade(
    void* hRequest,
    uintptr_t dwContext);
]]
local wininet = ffi.load("wininet")
-- wininet.HttpWebSocketCompleteUpgrade(hRequest, dwContext)
-- hRequest : void*
-- dwContext : UINT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const HttpWebSocketCompleteUpgrade = lib.func('__stdcall', 'HttpWebSocketCompleteUpgrade', 'void *', ['void *', 'uintptr_t']);
// HttpWebSocketCompleteUpgrade(hRequest, dwContext)
// hRequest : void* -> 'void *'
// dwContext : UINT_PTR -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WININET.dll", {
  HttpWebSocketCompleteUpgrade: { parameters: ["pointer", "usize"], result: "pointer" },
});
// lib.symbols.HttpWebSocketCompleteUpgrade(hRequest, dwContext)
// hRequest : void* -> "pointer"
// dwContext : UINT_PTR -> "usize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* HttpWebSocketCompleteUpgrade(
    void* hRequest,
    size_t dwContext);
C, "WININET.dll");
// $ffi->HttpWebSocketCompleteUpgrade(hRequest, dwContext);
// hRequest : void*
// dwContext : UINT_PTR
// 構造体/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 Wininet extends StdCallLibrary {
    Wininet INSTANCE = Native.load("wininet", Wininet.class);
    Pointer HttpWebSocketCompleteUpgrade(
        Pointer hRequest,   // void*
        long dwContext   // UINT_PTR
    );
}
@[Link("wininet")]
lib LibWININET
  fun HttpWebSocketCompleteUpgrade = HttpWebSocketCompleteUpgrade(
    hRequest : Void*,   # void*
    dwContext : LibC::SizeT   # UINT_PTR
  ) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef HttpWebSocketCompleteUpgradeNative = Pointer<Void> Function(Pointer<Void>, UintPtr);
typedef HttpWebSocketCompleteUpgradeDart = Pointer<Void> Function(Pointer<Void>, int);
final HttpWebSocketCompleteUpgrade = DynamicLibrary.open('WININET.dll')
    .lookupFunction<HttpWebSocketCompleteUpgradeNative, HttpWebSocketCompleteUpgradeDart>('HttpWebSocketCompleteUpgrade');
// hRequest : void* -> Pointer<Void>
// dwContext : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HttpWebSocketCompleteUpgrade(
  hRequest: Pointer;   // void*
  dwContext: NativeUInt   // UINT_PTR
): Pointer; stdcall;
  external 'WININET.dll' name 'HttpWebSocketCompleteUpgrade';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HttpWebSocketCompleteUpgrade"
  c_HttpWebSocketCompleteUpgrade :: Ptr () -> CUIntPtr -> IO (Ptr ())
-- hRequest : void* -> Ptr ()
-- dwContext : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let httpwebsocketcompleteupgrade =
  foreign "HttpWebSocketCompleteUpgrade"
    ((ptr void) @-> size_t @-> returning (ptr void))
(* hRequest : void* -> (ptr void) *)
(* dwContext : UINT_PTR -> size_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)

(cffi:defcfun ("HttpWebSocketCompleteUpgrade" http-web-socket-complete-upgrade :convention :stdcall) :pointer
  (h-request :pointer)   ; void*
  (dw-context :uint64))   ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HttpWebSocketCompleteUpgrade = Win32::API::More->new('WININET',
    'LPVOID HttpWebSocketCompleteUpgrade(LPVOID hRequest, WPARAM dwContext)');
# my $ret = $HttpWebSocketCompleteUpgrade->Call($hRequest, $dwContext);
# hRequest : void* -> LPVOID
# dwContext : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。