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

WinHttpProtocolReceive

関数
昇格したプロトコル接続からデータを受信する。
DLLWINHTTP.dll呼出規約winapi

シグネチャ

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

DWORD WinHttpProtocolReceive(
    void* ProtocolHandle,
    ULONGLONG Flags,
    void* pvBuffer,
    DWORD dwBufferLength,
    DWORD* pdwBytesRead
);

パラメーター

名前方向
ProtocolHandlevoid*in
FlagsULONGLONGin
pvBuffervoid*out
dwBufferLengthDWORDin
pdwBytesReadDWORD*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD WinHttpProtocolReceive(
    void* ProtocolHandle,
    ULONGLONG Flags,
    void* pvBuffer,
    DWORD dwBufferLength,
    DWORD* pdwBytesRead
);
[DllImport("WINHTTP.dll", ExactSpelling = true)]
static extern uint WinHttpProtocolReceive(
    IntPtr ProtocolHandle,   // void*
    ulong Flags,   // ULONGLONG
    IntPtr pvBuffer,   // void* out
    uint dwBufferLength,   // DWORD
    ref uint pdwBytesRead   // DWORD* in/out
);
<DllImport("WINHTTP.dll", ExactSpelling:=True)>
Public Shared Function WinHttpProtocolReceive(
    ProtocolHandle As IntPtr,   ' void*
    Flags As ULong,   ' ULONGLONG
    pvBuffer As IntPtr,   ' void* out
    dwBufferLength As UInteger,   ' DWORD
    ByRef pdwBytesRead As UInteger   ' DWORD* in/out
) As UInteger
End Function
' ProtocolHandle : void*
' Flags : ULONGLONG
' pvBuffer : void* out
' dwBufferLength : DWORD
' pdwBytesRead : DWORD* in/out
Declare PtrSafe Function WinHttpProtocolReceive Lib "winhttp" ( _
    ByVal ProtocolHandle As LongPtr, _
    ByVal Flags As LongLong, _
    ByVal pvBuffer As LongPtr, _
    ByVal dwBufferLength As Long, _
    ByRef pdwBytesRead As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinHttpProtocolReceive = ctypes.windll.winhttp.WinHttpProtocolReceive
WinHttpProtocolReceive.restype = wintypes.DWORD
WinHttpProtocolReceive.argtypes = [
    ctypes.POINTER(None),  # ProtocolHandle : void*
    ctypes.c_ulonglong,  # Flags : ULONGLONG
    ctypes.POINTER(None),  # pvBuffer : void* out
    wintypes.DWORD,  # dwBufferLength : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pdwBytesRead : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINHTTP.dll')
WinHttpProtocolReceive = Fiddle::Function.new(
  lib['WinHttpProtocolReceive'],
  [
    Fiddle::TYPE_VOIDP,  # ProtocolHandle : void*
    -Fiddle::TYPE_LONG_LONG,  # Flags : ULONGLONG
    Fiddle::TYPE_VOIDP,  # pvBuffer : void* out
    -Fiddle::TYPE_INT,  # dwBufferLength : DWORD
    Fiddle::TYPE_VOIDP,  # pdwBytesRead : DWORD* in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "winhttp")]
extern "system" {
    fn WinHttpProtocolReceive(
        ProtocolHandle: *mut (),  // void*
        Flags: u64,  // ULONGLONG
        pvBuffer: *mut (),  // void* out
        dwBufferLength: u32,  // DWORD
        pdwBytesRead: *mut u32  // DWORD* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WINHTTP.dll")]
public static extern uint WinHttpProtocolReceive(IntPtr ProtocolHandle, ulong Flags, IntPtr pvBuffer, uint dwBufferLength, ref uint pdwBytesRead);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpProtocolReceive' -Namespace Win32 -PassThru
# $api::WinHttpProtocolReceive(ProtocolHandle, Flags, pvBuffer, dwBufferLength, pdwBytesRead)
#uselib "WINHTTP.dll"
#func global WinHttpProtocolReceive "WinHttpProtocolReceive" sptr, sptr, sptr, sptr, sptr
; WinHttpProtocolReceive ProtocolHandle, Flags, pvBuffer, dwBufferLength, varptr(pdwBytesRead)   ; 戻り値は stat
; ProtocolHandle : void* -> "sptr"
; Flags : ULONGLONG -> "sptr"
; pvBuffer : void* out -> "sptr"
; dwBufferLength : DWORD -> "sptr"
; pdwBytesRead : DWORD* in/out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WINHTTP.dll"
#cfunc global WinHttpProtocolReceive "WinHttpProtocolReceive" sptr, int64, sptr, int, var
; res = WinHttpProtocolReceive(ProtocolHandle, Flags, pvBuffer, dwBufferLength, pdwBytesRead)
; ProtocolHandle : void* -> "sptr"
; Flags : ULONGLONG -> "int64"
; pvBuffer : void* out -> "sptr"
; dwBufferLength : DWORD -> "int"
; pdwBytesRead : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD WinHttpProtocolReceive(void* ProtocolHandle, ULONGLONG Flags, void* pvBuffer, DWORD dwBufferLength, DWORD* pdwBytesRead)
#uselib "WINHTTP.dll"
#cfunc global WinHttpProtocolReceive "WinHttpProtocolReceive" intptr, int64, intptr, int, var
; res = WinHttpProtocolReceive(ProtocolHandle, Flags, pvBuffer, dwBufferLength, pdwBytesRead)
; ProtocolHandle : void* -> "intptr"
; Flags : ULONGLONG -> "int64"
; pvBuffer : void* out -> "intptr"
; dwBufferLength : DWORD -> "int"
; pdwBytesRead : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhttp = windows.NewLazySystemDLL("WINHTTP.dll")
	procWinHttpProtocolReceive = winhttp.NewProc("WinHttpProtocolReceive")
)

// ProtocolHandle (void*), Flags (ULONGLONG), pvBuffer (void* out), dwBufferLength (DWORD), pdwBytesRead (DWORD* in/out)
r1, _, err := procWinHttpProtocolReceive.Call(
	uintptr(ProtocolHandle),
	uintptr(Flags),
	uintptr(pvBuffer),
	uintptr(dwBufferLength),
	uintptr(pdwBytesRead),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WinHttpProtocolReceive(
  ProtocolHandle: Pointer;   // void*
  Flags: UInt64;   // ULONGLONG
  pvBuffer: Pointer;   // void* out
  dwBufferLength: DWORD;   // DWORD
  pdwBytesRead: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'WINHTTP.dll' name 'WinHttpProtocolReceive';
result := DllCall("WINHTTP\WinHttpProtocolReceive"
    , "Ptr", ProtocolHandle   ; void*
    , "Int64", Flags   ; ULONGLONG
    , "Ptr", pvBuffer   ; void* out
    , "UInt", dwBufferLength   ; DWORD
    , "Ptr", pdwBytesRead   ; DWORD* in/out
    , "UInt")   ; return: DWORD
●WinHttpProtocolReceive(ProtocolHandle, Flags, pvBuffer, dwBufferLength, pdwBytesRead) = DLL("WINHTTP.dll", "dword WinHttpProtocolReceive(void*, qword, void*, dword, void*)")
# 呼び出し: WinHttpProtocolReceive(ProtocolHandle, Flags, pvBuffer, dwBufferLength, pdwBytesRead)
# ProtocolHandle : void* -> "void*"
# Flags : ULONGLONG -> "qword"
# pvBuffer : void* out -> "void*"
# dwBufferLength : DWORD -> "dword"
# pdwBytesRead : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。