ホーム › Networking.WinHttp › WinHttpReadDataEx
WinHttpReadDataEx
関数HTTP応答から拡張フラグ付きでデータを読み取る。
シグネチャ
// WINHTTP.dll
#include <windows.h>
DWORD WinHttpReadDataEx(
void* hRequest,
void* lpBuffer,
DWORD dwNumberOfBytesToRead,
DWORD* lpdwNumberOfBytesRead,
ULONGLONG ullFlags,
DWORD cbProperty,
void* pvProperty // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hRequest | void* | inout | 以前の WinHttpOpenRequest の呼び出しから返された HINTERNET ハンドルです。 WinHttpReadDataEx を呼び出す前に、このハンドルに対して WinHttpReceiveResponse または WinHttpQueryDataAvailable を呼び出し、その処理が完了している必要があります。WinHttpReceiveResponse の完了直後に WinHttpReadDataEx を呼び出すとバッファコピーのコストを回避できますが、その場合はアプリケーションで読み取りに固定長バッファを使用する必要があります。 |
| lpBuffer | void* | out | 読み取ったデータを受け取るバッファへのポインターです。このバッファは WinHttpReadDataEx が完了するまで有効なまま保持してください。 |
| dwNumberOfBytesToRead | DWORD | in | 読み取るバイト数を含む符号なし長整数値です。 |
| lpdwNumberOfBytesRead | DWORD* | inout | 読み取られたバイト数を受け取る符号なし長整数変数へのポインターです。 WinHttpReadDataEx は、何らかの処理やエラーチェックを行う前にこの値をゼロに設定します。WinHTTP を非同期で使用する場合は、常にこのパラメーターを NULL に設定し、コールバック関数内で情報を取得してください。これを行わないとメモリフォールトが発生する可能性があります。 |
| ullFlags | ULONGLONG | in | WINHTTP_READ_DATA_EX_FLAG_FILL_BUFFER を渡すと、指定したデータバッファが満たされるか、または応答が完了するまで、WinHttp は WinHttpReadDataEx の呼び出しを完了しません。このフラグを渡すと、この API の動作は WinHttpReadData と同等になります。 |
| cbProperty | DWORD | in | 予約済みです。0 を渡してください。 |
| pvProperty | void* | inoptional | 予約済みです。NULL を渡してください。 |
戻り値の型: DWORD
公式ドキュメント
WinHttpOpenRequest 関数によって開かれたハンドルからデータを読み取ります。
戻り値
操作の結果を示すステータスコードです。返されるエラーコードには次のものがあります。
| エラーコード | 説明 |
|---|---|
| サーバーとの接続がリセットまたは終了されたか、互換性のない SSL プロトコルが検出されました。たとえば、WinHTTP 5.1 はクライアントが明示的に有効化しない限り SSL2 をサポートしません。 | |
| 指定されたハンドルが正しい状態にないため、要求された操作を実行できません。 | |
| 指定されたハンドルの種類がこの操作に対して正しくありません。 | |
| 内部エラーが発生しました。 | |
| 操作がキャンセルされました。通常は、操作が完了する前に、要求を処理していたハンドルが閉じられたことが原因です。 | |
| 受信した応答が WinHTTP の内部サイズ制限を超えた場合に返されます。 | |
| 要求がタイムアウトしました。 | |
| 要求された操作を完了するための十分なメモリがありませんでした。(Windows エラーコード) |
解説(Remarks)
既定では、WinHttpReadDataEx は、指定したバッファに何らかの量のデータが書き込まれた時点で返ります(この関数が指定したバッファを常に完全に満たすとは限りません)。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// WINHTTP.dll
#include <windows.h>
DWORD WinHttpReadDataEx(
void* hRequest,
void* lpBuffer,
DWORD dwNumberOfBytesToRead,
DWORD* lpdwNumberOfBytesRead,
ULONGLONG ullFlags,
DWORD cbProperty,
void* pvProperty // optional
);[DllImport("WINHTTP.dll", ExactSpelling = true)]
static extern uint WinHttpReadDataEx(
IntPtr hRequest, // void* in/out
IntPtr lpBuffer, // void* out
uint dwNumberOfBytesToRead, // DWORD
ref uint lpdwNumberOfBytesRead, // DWORD* in/out
ulong ullFlags, // ULONGLONG
uint cbProperty, // DWORD
IntPtr pvProperty // void* optional
);<DllImport("WINHTTP.dll", ExactSpelling:=True)>
Public Shared Function WinHttpReadDataEx(
hRequest As IntPtr, ' void* in/out
lpBuffer As IntPtr, ' void* out
dwNumberOfBytesToRead As UInteger, ' DWORD
ByRef lpdwNumberOfBytesRead As UInteger, ' DWORD* in/out
ullFlags As ULong, ' ULONGLONG
cbProperty As UInteger, ' DWORD
pvProperty As IntPtr ' void* optional
) As UInteger
End Function' hRequest : void* in/out
' lpBuffer : void* out
' dwNumberOfBytesToRead : DWORD
' lpdwNumberOfBytesRead : DWORD* in/out
' ullFlags : ULONGLONG
' cbProperty : DWORD
' pvProperty : void* optional
Declare PtrSafe Function WinHttpReadDataEx Lib "winhttp" ( _
ByVal hRequest As LongPtr, _
ByVal lpBuffer As LongPtr, _
ByVal dwNumberOfBytesToRead As Long, _
ByRef lpdwNumberOfBytesRead As Long, _
ByVal ullFlags As LongLong, _
ByVal cbProperty As Long, _
ByVal pvProperty As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WinHttpReadDataEx = ctypes.windll.winhttp.WinHttpReadDataEx
WinHttpReadDataEx.restype = wintypes.DWORD
WinHttpReadDataEx.argtypes = [
ctypes.POINTER(None), # hRequest : void* in/out
ctypes.POINTER(None), # lpBuffer : void* out
wintypes.DWORD, # dwNumberOfBytesToRead : DWORD
ctypes.POINTER(wintypes.DWORD), # lpdwNumberOfBytesRead : DWORD* in/out
ctypes.c_ulonglong, # ullFlags : ULONGLONG
wintypes.DWORD, # cbProperty : DWORD
ctypes.POINTER(None), # pvProperty : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINHTTP.dll')
WinHttpReadDataEx = Fiddle::Function.new(
lib['WinHttpReadDataEx'],
[
Fiddle::TYPE_VOIDP, # hRequest : void* in/out
Fiddle::TYPE_VOIDP, # lpBuffer : void* out
-Fiddle::TYPE_INT, # dwNumberOfBytesToRead : DWORD
Fiddle::TYPE_VOIDP, # lpdwNumberOfBytesRead : DWORD* in/out
-Fiddle::TYPE_LONG_LONG, # ullFlags : ULONGLONG
-Fiddle::TYPE_INT, # cbProperty : DWORD
Fiddle::TYPE_VOIDP, # pvProperty : void* optional
],
-Fiddle::TYPE_INT)#[link(name = "winhttp")]
extern "system" {
fn WinHttpReadDataEx(
hRequest: *mut (), // void* in/out
lpBuffer: *mut (), // void* out
dwNumberOfBytesToRead: u32, // DWORD
lpdwNumberOfBytesRead: *mut u32, // DWORD* in/out
ullFlags: u64, // ULONGLONG
cbProperty: u32, // DWORD
pvProperty: *mut () // void* optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WINHTTP.dll")]
public static extern uint WinHttpReadDataEx(IntPtr hRequest, IntPtr lpBuffer, uint dwNumberOfBytesToRead, ref uint lpdwNumberOfBytesRead, ulong ullFlags, uint cbProperty, IntPtr pvProperty);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpReadDataEx' -Namespace Win32 -PassThru
# $api::WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty)#uselib "WINHTTP.dll"
#func global WinHttpReadDataEx "WinHttpReadDataEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WinHttpReadDataEx hRequest, lpBuffer, dwNumberOfBytesToRead, varptr(lpdwNumberOfBytesRead), ullFlags, cbProperty, pvProperty ; 戻り値は stat
; hRequest : void* in/out -> "sptr"
; lpBuffer : void* out -> "sptr"
; dwNumberOfBytesToRead : DWORD -> "sptr"
; lpdwNumberOfBytesRead : DWORD* in/out -> "sptr"
; ullFlags : ULONGLONG -> "sptr"
; cbProperty : DWORD -> "sptr"
; pvProperty : void* optional -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WINHTTP.dll" #cfunc global WinHttpReadDataEx "WinHttpReadDataEx" sptr, sptr, int, var, int64, int, sptr ; res = WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty) ; hRequest : void* in/out -> "sptr" ; lpBuffer : void* out -> "sptr" ; dwNumberOfBytesToRead : DWORD -> "int" ; lpdwNumberOfBytesRead : DWORD* in/out -> "var" ; ullFlags : ULONGLONG -> "int64" ; cbProperty : DWORD -> "int" ; pvProperty : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "WINHTTP.dll" #cfunc global WinHttpReadDataEx "WinHttpReadDataEx" sptr, sptr, int, sptr, int64, int, sptr ; res = WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, varptr(lpdwNumberOfBytesRead), ullFlags, cbProperty, pvProperty) ; hRequest : void* in/out -> "sptr" ; lpBuffer : void* out -> "sptr" ; dwNumberOfBytesToRead : DWORD -> "int" ; lpdwNumberOfBytesRead : DWORD* in/out -> "sptr" ; ullFlags : ULONGLONG -> "int64" ; cbProperty : DWORD -> "int" ; pvProperty : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD WinHttpReadDataEx(void* hRequest, void* lpBuffer, DWORD dwNumberOfBytesToRead, DWORD* lpdwNumberOfBytesRead, ULONGLONG ullFlags, DWORD cbProperty, void* pvProperty) #uselib "WINHTTP.dll" #cfunc global WinHttpReadDataEx "WinHttpReadDataEx" intptr, intptr, int, var, int64, int, intptr ; res = WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty) ; hRequest : void* in/out -> "intptr" ; lpBuffer : void* out -> "intptr" ; dwNumberOfBytesToRead : DWORD -> "int" ; lpdwNumberOfBytesRead : DWORD* in/out -> "var" ; ullFlags : ULONGLONG -> "int64" ; cbProperty : DWORD -> "int" ; pvProperty : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD WinHttpReadDataEx(void* hRequest, void* lpBuffer, DWORD dwNumberOfBytesToRead, DWORD* lpdwNumberOfBytesRead, ULONGLONG ullFlags, DWORD cbProperty, void* pvProperty) #uselib "WINHTTP.dll" #cfunc global WinHttpReadDataEx "WinHttpReadDataEx" intptr, intptr, int, intptr, int64, int, intptr ; res = WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, varptr(lpdwNumberOfBytesRead), ullFlags, cbProperty, pvProperty) ; hRequest : void* in/out -> "intptr" ; lpBuffer : void* out -> "intptr" ; dwNumberOfBytesToRead : DWORD -> "int" ; lpdwNumberOfBytesRead : DWORD* in/out -> "intptr" ; ullFlags : ULONGLONG -> "int64" ; cbProperty : DWORD -> "int" ; pvProperty : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winhttp = windows.NewLazySystemDLL("WINHTTP.dll")
procWinHttpReadDataEx = winhttp.NewProc("WinHttpReadDataEx")
)
// hRequest (void* in/out), lpBuffer (void* out), dwNumberOfBytesToRead (DWORD), lpdwNumberOfBytesRead (DWORD* in/out), ullFlags (ULONGLONG), cbProperty (DWORD), pvProperty (void* optional)
r1, _, err := procWinHttpReadDataEx.Call(
uintptr(hRequest),
uintptr(lpBuffer),
uintptr(dwNumberOfBytesToRead),
uintptr(lpdwNumberOfBytesRead),
uintptr(ullFlags),
uintptr(cbProperty),
uintptr(pvProperty),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction WinHttpReadDataEx(
hRequest: Pointer; // void* in/out
lpBuffer: Pointer; // void* out
dwNumberOfBytesToRead: DWORD; // DWORD
lpdwNumberOfBytesRead: Pointer; // DWORD* in/out
ullFlags: UInt64; // ULONGLONG
cbProperty: DWORD; // DWORD
pvProperty: Pointer // void* optional
): DWORD; stdcall;
external 'WINHTTP.dll' name 'WinHttpReadDataEx';result := DllCall("WINHTTP\WinHttpReadDataEx"
, "Ptr", hRequest ; void* in/out
, "Ptr", lpBuffer ; void* out
, "UInt", dwNumberOfBytesToRead ; DWORD
, "Ptr", lpdwNumberOfBytesRead ; DWORD* in/out
, "Int64", ullFlags ; ULONGLONG
, "UInt", cbProperty ; DWORD
, "Ptr", pvProperty ; void* optional
, "UInt") ; return: DWORD●WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty) = DLL("WINHTTP.dll", "dword WinHttpReadDataEx(void*, void*, dword, void*, qword, dword, void*)")
# 呼び出し: WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty)
# hRequest : void* in/out -> "void*"
# lpBuffer : void* out -> "void*"
# dwNumberOfBytesToRead : DWORD -> "dword"
# lpdwNumberOfBytesRead : DWORD* in/out -> "void*"
# ullFlags : ULONGLONG -> "qword"
# cbProperty : DWORD -> "dword"
# pvProperty : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winhttp" fn WinHttpReadDataEx(
hRequest: ?*anyopaque, // void* in/out
lpBuffer: ?*anyopaque, // void* out
dwNumberOfBytesToRead: u32, // DWORD
lpdwNumberOfBytesRead: [*c]u32, // DWORD* in/out
ullFlags: u64, // ULONGLONG
cbProperty: u32, // DWORD
pvProperty: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) u32;proc WinHttpReadDataEx(
hRequest: pointer, # void* in/out
lpBuffer: pointer, # void* out
dwNumberOfBytesToRead: uint32, # DWORD
lpdwNumberOfBytesRead: ptr uint32, # DWORD* in/out
ullFlags: uint64, # ULONGLONG
cbProperty: uint32, # DWORD
pvProperty: pointer # void* optional
): uint32 {.importc: "WinHttpReadDataEx", stdcall, dynlib: "WINHTTP.dll".}pragma(lib, "winhttp");
extern(Windows)
uint WinHttpReadDataEx(
void* hRequest, // void* in/out
void* lpBuffer, // void* out
uint dwNumberOfBytesToRead, // DWORD
uint* lpdwNumberOfBytesRead, // DWORD* in/out
ulong ullFlags, // ULONGLONG
uint cbProperty, // DWORD
void* pvProperty // void* optional
);ccall((:WinHttpReadDataEx, "WINHTTP.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{Cvoid}, UInt32, Ptr{UInt32}, UInt64, UInt32, Ptr{Cvoid}),
hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty)
# hRequest : void* in/out -> Ptr{Cvoid}
# lpBuffer : void* out -> Ptr{Cvoid}
# dwNumberOfBytesToRead : DWORD -> UInt32
# lpdwNumberOfBytesRead : DWORD* in/out -> Ptr{UInt32}
# ullFlags : ULONGLONG -> UInt64
# cbProperty : DWORD -> UInt32
# pvProperty : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t WinHttpReadDataEx(
void* hRequest,
void* lpBuffer,
uint32_t dwNumberOfBytesToRead,
uint32_t* lpdwNumberOfBytesRead,
uint64_t ullFlags,
uint32_t cbProperty,
void* pvProperty);
]]
local winhttp = ffi.load("winhttp")
-- winhttp.WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty)
-- hRequest : void* in/out
-- lpBuffer : void* out
-- dwNumberOfBytesToRead : DWORD
-- lpdwNumberOfBytesRead : DWORD* in/out
-- ullFlags : ULONGLONG
-- cbProperty : DWORD
-- pvProperty : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WINHTTP.dll');
const WinHttpReadDataEx = lib.func('__stdcall', 'WinHttpReadDataEx', 'uint32_t', ['void *', 'void *', 'uint32_t', 'uint32_t *', 'uint64_t', 'uint32_t', 'void *']);
// WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty)
// hRequest : void* in/out -> 'void *'
// lpBuffer : void* out -> 'void *'
// dwNumberOfBytesToRead : DWORD -> 'uint32_t'
// lpdwNumberOfBytesRead : DWORD* in/out -> 'uint32_t *'
// ullFlags : ULONGLONG -> 'uint64_t'
// cbProperty : DWORD -> 'uint32_t'
// pvProperty : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WINHTTP.dll", {
WinHttpReadDataEx: { parameters: ["pointer", "pointer", "u32", "pointer", "u64", "u32", "pointer"], result: "u32" },
});
// lib.symbols.WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty)
// hRequest : void* in/out -> "pointer"
// lpBuffer : void* out -> "pointer"
// dwNumberOfBytesToRead : DWORD -> "u32"
// lpdwNumberOfBytesRead : DWORD* in/out -> "pointer"
// ullFlags : ULONGLONG -> "u64"
// cbProperty : DWORD -> "u32"
// pvProperty : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t WinHttpReadDataEx(
void* hRequest,
void* lpBuffer,
uint32_t dwNumberOfBytesToRead,
uint32_t* lpdwNumberOfBytesRead,
uint64_t ullFlags,
uint32_t cbProperty,
void* pvProperty);
C, "WINHTTP.dll");
// $ffi->WinHttpReadDataEx(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead, ullFlags, cbProperty, pvProperty);
// hRequest : void* in/out
// lpBuffer : void* out
// dwNumberOfBytesToRead : DWORD
// lpdwNumberOfBytesRead : DWORD* in/out
// ullFlags : ULONGLONG
// cbProperty : DWORD
// pvProperty : void* optional
// 構造体/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 Winhttp extends StdCallLibrary {
Winhttp INSTANCE = Native.load("winhttp", Winhttp.class);
int WinHttpReadDataEx(
Pointer hRequest, // void* in/out
Pointer lpBuffer, // void* out
int dwNumberOfBytesToRead, // DWORD
IntByReference lpdwNumberOfBytesRead, // DWORD* in/out
long ullFlags, // ULONGLONG
int cbProperty, // DWORD
Pointer pvProperty // void* optional
);
}@[Link("winhttp")]
lib LibWINHTTP
fun WinHttpReadDataEx = WinHttpReadDataEx(
hRequest : Void*, # void* in/out
lpBuffer : Void*, # void* out
dwNumberOfBytesToRead : UInt32, # DWORD
lpdwNumberOfBytesRead : UInt32*, # DWORD* in/out
ullFlags : UInt64, # ULONGLONG
cbProperty : UInt32, # DWORD
pvProperty : Void* # void* optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WinHttpReadDataExNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Uint32>, Uint64, Uint32, Pointer<Void>);
typedef WinHttpReadDataExDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Uint32>, int, int, Pointer<Void>);
final WinHttpReadDataEx = DynamicLibrary.open('WINHTTP.dll')
.lookupFunction<WinHttpReadDataExNative, WinHttpReadDataExDart>('WinHttpReadDataEx');
// hRequest : void* in/out -> Pointer<Void>
// lpBuffer : void* out -> Pointer<Void>
// dwNumberOfBytesToRead : DWORD -> Uint32
// lpdwNumberOfBytesRead : DWORD* in/out -> Pointer<Uint32>
// ullFlags : ULONGLONG -> Uint64
// cbProperty : DWORD -> Uint32
// pvProperty : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WinHttpReadDataEx(
hRequest: Pointer; // void* in/out
lpBuffer: Pointer; // void* out
dwNumberOfBytesToRead: DWORD; // DWORD
lpdwNumberOfBytesRead: Pointer; // DWORD* in/out
ullFlags: UInt64; // ULONGLONG
cbProperty: DWORD; // DWORD
pvProperty: Pointer // void* optional
): DWORD; stdcall;
external 'WINHTTP.dll' name 'WinHttpReadDataEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WinHttpReadDataEx"
c_WinHttpReadDataEx :: Ptr () -> Ptr () -> Word32 -> Ptr Word32 -> Word64 -> Word32 -> Ptr () -> IO Word32
-- hRequest : void* in/out -> Ptr ()
-- lpBuffer : void* out -> Ptr ()
-- dwNumberOfBytesToRead : DWORD -> Word32
-- lpdwNumberOfBytesRead : DWORD* in/out -> Ptr Word32
-- ullFlags : ULONGLONG -> Word64
-- cbProperty : DWORD -> Word32
-- pvProperty : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let winhttpreaddataex =
foreign "WinHttpReadDataEx"
((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> uint64_t @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* hRequest : void* in/out -> (ptr void) *)
(* lpBuffer : void* out -> (ptr void) *)
(* dwNumberOfBytesToRead : DWORD -> uint32_t *)
(* lpdwNumberOfBytesRead : DWORD* in/out -> (ptr uint32_t) *)
(* ullFlags : ULONGLONG -> uint64_t *)
(* cbProperty : DWORD -> uint32_t *)
(* pvProperty : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winhttp (t "WINHTTP.dll"))
(cffi:use-foreign-library winhttp)
(cffi:defcfun ("WinHttpReadDataEx" win-http-read-data-ex :convention :stdcall) :uint32
(h-request :pointer) ; void* in/out
(lp-buffer :pointer) ; void* out
(dw-number-of-bytes-to-read :uint32) ; DWORD
(lpdw-number-of-bytes-read :pointer) ; DWORD* in/out
(ull-flags :uint64) ; ULONGLONG
(cb-property :uint32) ; DWORD
(pv-property :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WinHttpReadDataEx = Win32::API::More->new('WINHTTP',
'DWORD WinHttpReadDataEx(LPVOID hRequest, LPVOID lpBuffer, DWORD dwNumberOfBytesToRead, LPVOID lpdwNumberOfBytesRead, UINT64 ullFlags, DWORD cbProperty, LPVOID pvProperty)');
# my $ret = $WinHttpReadDataEx->Call($hRequest, $lpBuffer, $dwNumberOfBytesToRead, $lpdwNumberOfBytesRead, $ullFlags, $cbProperty, $pvProperty);
# hRequest : void* in/out -> LPVOID
# lpBuffer : void* out -> LPVOID
# dwNumberOfBytesToRead : DWORD -> DWORD
# lpdwNumberOfBytesRead : DWORD* in/out -> LPVOID
# ullFlags : ULONGLONG -> UINT64
# cbProperty : DWORD -> DWORD
# pvProperty : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f WinHttpReadData — HTTP応答からデータをバッファへ読み取る。