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

InternetQueryOptionW

関数
WinINetハンドルの指定したオプション値を取得する(Unicode)。
DLLWININET.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

BOOL InternetQueryOptionW(
    void* hInternet,   // optional
    DWORD dwOption,
    void* lpBuffer,   // optional
    DWORD* lpdwBufferLength
);

パラメーター

名前方向
hInternetvoid*inoptional
dwOptionDWORDin
lpBuffervoid*outoptional
lpdwBufferLengthDWORD*inout

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL InternetQueryOptionW(
    void* hInternet,   // optional
    DWORD dwOption,
    void* lpBuffer,   // optional
    DWORD* lpdwBufferLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool InternetQueryOptionW(
    IntPtr hInternet,   // void* optional
    uint dwOption,   // DWORD
    IntPtr lpBuffer,   // void* optional, out
    ref uint lpdwBufferLength   // DWORD* in/out
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function InternetQueryOptionW(
    hInternet As IntPtr,   ' void* optional
    dwOption As UInteger,   ' DWORD
    lpBuffer As IntPtr,   ' void* optional, out
    ByRef lpdwBufferLength As UInteger   ' DWORD* in/out
) As Boolean
End Function
' hInternet : void* optional
' dwOption : DWORD
' lpBuffer : void* optional, out
' lpdwBufferLength : DWORD* in/out
Declare PtrSafe Function InternetQueryOptionW Lib "wininet" ( _
    ByVal hInternet As LongPtr, _
    ByVal dwOption As Long, _
    ByVal lpBuffer As LongPtr, _
    ByRef lpdwBufferLength As Long) 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

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

lib = Fiddle.dlopen('WININET.dll')
InternetQueryOptionW = Fiddle::Function.new(
  lib['InternetQueryOptionW'],
  [
    Fiddle::TYPE_VOIDP,  # hInternet : void* optional
    -Fiddle::TYPE_INT,  # dwOption : DWORD
    Fiddle::TYPE_VOIDP,  # lpBuffer : void* optional, out
    Fiddle::TYPE_VOIDP,  # lpdwBufferLength : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn InternetQueryOptionW(
        hInternet: *mut (),  // void* optional
        dwOption: u32,  // DWORD
        lpBuffer: *mut (),  // void* optional, out
        lpdwBufferLength: *mut u32  // DWORD* 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 InternetQueryOptionW(IntPtr hInternet, uint dwOption, IntPtr lpBuffer, ref uint lpdwBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetQueryOptionW' -Namespace Win32 -PassThru
# $api::InternetQueryOptionW(hInternet, dwOption, lpBuffer, lpdwBufferLength)
#uselib "WININET.dll"
#func global InternetQueryOptionW "InternetQueryOptionW" wptr, wptr, wptr, wptr
; InternetQueryOptionW hInternet, dwOption, lpBuffer, varptr(lpdwBufferLength)   ; 戻り値は stat
; hInternet : void* optional -> "wptr"
; dwOption : DWORD -> "wptr"
; lpBuffer : void* optional, out -> "wptr"
; lpdwBufferLength : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global InternetQueryOptionW "InternetQueryOptionW" sptr, int, sptr, var
; res = InternetQueryOptionW(hInternet, dwOption, lpBuffer, lpdwBufferLength)
; hInternet : void* optional -> "sptr"
; dwOption : DWORD -> "int"
; lpBuffer : void* optional, out -> "sptr"
; lpdwBufferLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL InternetQueryOptionW(void* hInternet, DWORD dwOption, void* lpBuffer, DWORD* lpdwBufferLength)
#uselib "WININET.dll"
#cfunc global InternetQueryOptionW "InternetQueryOptionW" intptr, int, intptr, var
; res = InternetQueryOptionW(hInternet, dwOption, lpBuffer, lpdwBufferLength)
; hInternet : void* optional -> "intptr"
; dwOption : DWORD -> "int"
; lpBuffer : void* optional, out -> "intptr"
; lpdwBufferLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procInternetQueryOptionW = wininet.NewProc("InternetQueryOptionW")
)

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