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

HttpQueryInfoW

関数
HTTP応答のヘッダーや状態情報を問い合わせる(Unicode版)。
DLLWININET.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL HttpQueryInfoW(
    void* hRequest,
    DWORD dwInfoLevel,
    void* lpBuffer,   // optional
    DWORD* lpdwBufferLength,
    DWORD* lpdwIndex   // optional
);

パラメーター

名前方向
hRequestvoid*in
dwInfoLevelDWORDin
lpBuffervoid*inoutoptional
lpdwBufferLengthDWORD*inout
lpdwIndexDWORD*inoutoptional

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL HttpQueryInfoW(
    void* hRequest,
    DWORD dwInfoLevel,
    void* lpBuffer,   // optional
    DWORD* lpdwBufferLength,
    DWORD* lpdwIndex   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool HttpQueryInfoW(
    IntPtr hRequest,   // void*
    uint dwInfoLevel,   // DWORD
    IntPtr lpBuffer,   // void* optional, in/out
    ref uint lpdwBufferLength,   // DWORD* in/out
    IntPtr lpdwIndex   // DWORD* optional, in/out
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function HttpQueryInfoW(
    hRequest As IntPtr,   ' void*
    dwInfoLevel As UInteger,   ' DWORD
    lpBuffer As IntPtr,   ' void* optional, in/out
    ByRef lpdwBufferLength As UInteger,   ' DWORD* in/out
    lpdwIndex As IntPtr   ' DWORD* optional, in/out
) As Boolean
End Function
' hRequest : void*
' dwInfoLevel : DWORD
' lpBuffer : void* optional, in/out
' lpdwBufferLength : DWORD* in/out
' lpdwIndex : DWORD* optional, in/out
Declare PtrSafe Function HttpQueryInfoW Lib "wininet" ( _
    ByVal hRequest As LongPtr, _
    ByVal dwInfoLevel As Long, _
    ByVal lpBuffer As LongPtr, _
    ByRef lpdwBufferLength As Long, _
    ByVal lpdwIndex As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HttpQueryInfoW = ctypes.windll.wininet.HttpQueryInfoW
HttpQueryInfoW.restype = wintypes.BOOL
HttpQueryInfoW.argtypes = [
    ctypes.POINTER(None),  # hRequest : void*
    wintypes.DWORD,  # dwInfoLevel : DWORD
    ctypes.POINTER(None),  # lpBuffer : void* optional, in/out
    ctypes.POINTER(wintypes.DWORD),  # lpdwBufferLength : DWORD* in/out
    ctypes.POINTER(wintypes.DWORD),  # lpdwIndex : DWORD* optional, in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
HttpQueryInfoW = Fiddle::Function.new(
  lib['HttpQueryInfoW'],
  [
    Fiddle::TYPE_VOIDP,  # hRequest : void*
    -Fiddle::TYPE_INT,  # dwInfoLevel : DWORD
    Fiddle::TYPE_VOIDP,  # lpBuffer : void* optional, in/out
    Fiddle::TYPE_VOIDP,  # lpdwBufferLength : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # lpdwIndex : DWORD* optional, in/out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn HttpQueryInfoW(
        hRequest: *mut (),  // void*
        dwInfoLevel: u32,  // DWORD
        lpBuffer: *mut (),  // void* optional, in/out
        lpdwBufferLength: *mut u32,  // DWORD* in/out
        lpdwIndex: *mut u32  // DWORD* optional, in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool HttpQueryInfoW(IntPtr hRequest, uint dwInfoLevel, IntPtr lpBuffer, ref uint lpdwBufferLength, IntPtr lpdwIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_HttpQueryInfoW' -Namespace Win32 -PassThru
# $api::HttpQueryInfoW(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex)
#uselib "WININET.dll"
#func global HttpQueryInfoW "HttpQueryInfoW" wptr, wptr, wptr, wptr, wptr
; HttpQueryInfoW hRequest, dwInfoLevel, lpBuffer, varptr(lpdwBufferLength), varptr(lpdwIndex)   ; 戻り値は stat
; hRequest : void* -> "wptr"
; dwInfoLevel : DWORD -> "wptr"
; lpBuffer : void* optional, in/out -> "wptr"
; lpdwBufferLength : DWORD* in/out -> "wptr"
; lpdwIndex : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global HttpQueryInfoW "HttpQueryInfoW" sptr, int, sptr, var, var
; res = HttpQueryInfoW(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex)
; hRequest : void* -> "sptr"
; dwInfoLevel : DWORD -> "int"
; lpBuffer : void* optional, in/out -> "sptr"
; lpdwBufferLength : DWORD* in/out -> "var"
; lpdwIndex : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL HttpQueryInfoW(void* hRequest, DWORD dwInfoLevel, void* lpBuffer, DWORD* lpdwBufferLength, DWORD* lpdwIndex)
#uselib "WININET.dll"
#cfunc global HttpQueryInfoW "HttpQueryInfoW" intptr, int, intptr, var, var
; res = HttpQueryInfoW(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex)
; hRequest : void* -> "intptr"
; dwInfoLevel : DWORD -> "int"
; lpBuffer : void* optional, in/out -> "intptr"
; lpdwBufferLength : DWORD* in/out -> "var"
; lpdwIndex : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procHttpQueryInfoW = wininet.NewProc("HttpQueryInfoW")
)

// hRequest (void*), dwInfoLevel (DWORD), lpBuffer (void* optional, in/out), lpdwBufferLength (DWORD* in/out), lpdwIndex (DWORD* optional, in/out)
r1, _, err := procHttpQueryInfoW.Call(
	uintptr(hRequest),
	uintptr(dwInfoLevel),
	uintptr(lpBuffer),
	uintptr(lpdwBufferLength),
	uintptr(lpdwIndex),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function HttpQueryInfoW(
  hRequest: Pointer;   // void*
  dwInfoLevel: DWORD;   // DWORD
  lpBuffer: Pointer;   // void* optional, in/out
  lpdwBufferLength: Pointer;   // DWORD* in/out
  lpdwIndex: Pointer   // DWORD* optional, in/out
): BOOL; stdcall;
  external 'WININET.dll' name 'HttpQueryInfoW';
result := DllCall("WININET\HttpQueryInfoW"
    , "Ptr", hRequest   ; void*
    , "UInt", dwInfoLevel   ; DWORD
    , "Ptr", lpBuffer   ; void* optional, in/out
    , "Ptr", lpdwBufferLength   ; DWORD* in/out
    , "Ptr", lpdwIndex   ; DWORD* optional, in/out
    , "Int")   ; return: BOOL
●HttpQueryInfoW(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex) = DLL("WININET.dll", "bool HttpQueryInfoW(void*, dword, void*, void*, void*)")
# 呼び出し: HttpQueryInfoW(hRequest, dwInfoLevel, lpBuffer, lpdwBufferLength, lpdwIndex)
# hRequest : void* -> "void*"
# dwInfoLevel : DWORD -> "dword"
# lpBuffer : void* optional, in/out -> "void*"
# lpdwBufferLength : DWORD* in/out -> "void*"
# lpdwIndex : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。