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

WinHttpReceiveResponse

関数
送信した要求に対するHTTP応答を受信する。
DLLWINHTTP.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL WinHttpReceiveResponse(
    void* hRequest,
    void* lpReserved
);

パラメーター

名前方向
hRequestvoid*inout
lpReservedvoid*inout

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL WinHttpReceiveResponse(
    void* hRequest,
    void* lpReserved
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINHTTP.dll", SetLastError = true, ExactSpelling = true)]
static extern bool WinHttpReceiveResponse(
    IntPtr hRequest,   // void* in/out
    IntPtr lpReserved   // void* in/out
);
<DllImport("WINHTTP.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WinHttpReceiveResponse(
    hRequest As IntPtr,   ' void* in/out
    lpReserved As IntPtr   ' void* in/out
) As Boolean
End Function
' hRequest : void* in/out
' lpReserved : void* in/out
Declare PtrSafe Function WinHttpReceiveResponse Lib "winhttp" ( _
    ByVal hRequest As LongPtr, _
    ByVal lpReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinHttpReceiveResponse = ctypes.windll.winhttp.WinHttpReceiveResponse
WinHttpReceiveResponse.restype = wintypes.BOOL
WinHttpReceiveResponse.argtypes = [
    ctypes.POINTER(None),  # hRequest : void* in/out
    ctypes.POINTER(None),  # lpReserved : void* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINHTTP.dll')
WinHttpReceiveResponse = Fiddle::Function.new(
  lib['WinHttpReceiveResponse'],
  [
    Fiddle::TYPE_VOIDP,  # hRequest : void* in/out
    Fiddle::TYPE_VOIDP,  # lpReserved : void* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhttp")]
extern "system" {
    fn WinHttpReceiveResponse(
        hRequest: *mut (),  // void* in/out
        lpReserved: *mut ()  // void* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINHTTP.dll", SetLastError = true)]
public static extern bool WinHttpReceiveResponse(IntPtr hRequest, IntPtr lpReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpReceiveResponse' -Namespace Win32 -PassThru
# $api::WinHttpReceiveResponse(hRequest, lpReserved)
#uselib "WINHTTP.dll"
#func global WinHttpReceiveResponse "WinHttpReceiveResponse" sptr, sptr
; WinHttpReceiveResponse hRequest, lpReserved   ; 戻り値は stat
; hRequest : void* in/out -> "sptr"
; lpReserved : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WINHTTP.dll"
#cfunc global WinHttpReceiveResponse "WinHttpReceiveResponse" sptr, sptr
; res = WinHttpReceiveResponse(hRequest, lpReserved)
; hRequest : void* in/out -> "sptr"
; lpReserved : void* in/out -> "sptr"
; BOOL WinHttpReceiveResponse(void* hRequest, void* lpReserved)
#uselib "WINHTTP.dll"
#cfunc global WinHttpReceiveResponse "WinHttpReceiveResponse" intptr, intptr
; res = WinHttpReceiveResponse(hRequest, lpReserved)
; hRequest : void* in/out -> "intptr"
; lpReserved : void* in/out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhttp = windows.NewLazySystemDLL("WINHTTP.dll")
	procWinHttpReceiveResponse = winhttp.NewProc("WinHttpReceiveResponse")
)

// hRequest (void* in/out), lpReserved (void* in/out)
r1, _, err := procWinHttpReceiveResponse.Call(
	uintptr(hRequest),
	uintptr(lpReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function WinHttpReceiveResponse(
  hRequest: Pointer;   // void* in/out
  lpReserved: Pointer   // void* in/out
): BOOL; stdcall;
  external 'WINHTTP.dll' name 'WinHttpReceiveResponse';
result := DllCall("WINHTTP\WinHttpReceiveResponse"
    , "Ptr", hRequest   ; void* in/out
    , "Ptr", lpReserved   ; void* in/out
    , "Int")   ; return: BOOL
●WinHttpReceiveResponse(hRequest, lpReserved) = DLL("WINHTTP.dll", "bool WinHttpReceiveResponse(void*, void*)")
# 呼び出し: WinHttpReceiveResponse(hRequest, lpReserved)
# hRequest : void* in/out -> "void*"
# lpReserved : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。